473,626 Members | 3,675 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ajax multiple select php

How can I accomplish the following using AJAX / PHP:

I have a form with a text field and a search button next to the text
field. When I type something in the text field and hit the search
button a query is performed and the results are dynamically entered
into a multiple select box below the textfield without reloading the
page, or affecting other form elements. If no data is found then an
error message is displayed in place of the multiple select box.

Seems pretty basic, but I am having trouble getting things going...

Thanks

Feb 13 '07 #1
1 8217
On Feb 13, 12:52 am, trp...@gmail.co m wrote:
How can I accomplish the following using AJAX / PHP:

I have a form with a text field and a search button next to the text
field. When I type something in the text field and hit the search
button a query is performed and the results are dynamically entered
into a multiple select box below the textfield without reloading the
page, or affecting other form elements. If no data is found then an
error message is displayed in place of the multiple select box.

Seems pretty basic, but I am having trouble getting things going...

Thanks
What have you tried yet? :)
The basic idea is really sending the ajax request, registering
callback function for any input from ajax, and parsing the results. If
everything is fine, find the <selectobject , empty it and fill it
with results. If nothing is fine :) then find the <selectobject
anyway, put its style.display to 'none' (if you want to hide it) and
put some error text in the designated space.
The only problem can be how to parse the ajax response, where maybe
the best way may be sending the xml in response, and ajax know
perfectly well how to automatically convert this into a DOM model,
which you can use at your will. If you don't know how to do this,
here's the code:
function getAJAXXMLHandl er()
{
var xmlHttp = null;
try {
if (window.XMLHttp Request) { // Mozilla, Safari,...
xmlHttp = new XMLHttpRequest( );

if (xmlHttp.overri deMimeType)
xmlHttp.overrid eMimeType('text/xml');
else
xmlHttp = null;
} else if (window.ActiveX Object) { // IE
try {
xmlHttp = new ActiveXObject(" Msxml2.XMLHTTP" );
} catch (e) {
try {
xmlHttp = new ActiveXObject(" Microsoft.XMLHT TP");
} catch (e) {}
}
}
} catch ( e ) {}
return xmlHttp;
}
Later, when you get the response from the xmlHttp object, you capture
its xml document by calling:
var xmldoc = ajax.responseXM L;
and then
var documentRoot = xmlDocument.doc umentElement;
Once you get documentRoot, you can access all its children and
subchildren etc. by referencing .childNodes array attribute and that
is just wonderful :)

Feb 14 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
20065
by: dougwig | last post by:
I'm trying to handle the scenario where a user's session times out and and their ajax request triggers a redirection by the webserver (302 error?). I'm using Prototype 1.4 and the my works great with Firefox,but with IE6 the onFailure never gets called and the request never completes. My code: var ajaxReq = new Ajax.Request( url, {method: 'post', parameters:
10
4851
by: trpost | last post by:
I am using ajax / php where I am looking up some info from the database and populating a select list dynamically, however I am running into some sort of size limitation with the ajax.response object. If the string I am passing to javascript from php is too large javascript does not get it all the data. The magic number appears to be 6123 characters, anything below that it works fine, anything above and if I alert the ajax.response, I see...
1
2913
by: quill | last post by:
Hi I am making a chatroom script and it appears that the problem seems to be that my setTimeout's are conflicting. The logic is as follows: Run a login check every x seconds Run a trigger check every x seconds
1
4023
by: geevaa | last post by:
http://www.phpbuilder.com/columns/kassemi20050606.php3 XMLHttpRequest and AJAX for PHP programmers James Kassemi Introduction: Although the concept isn't entirely new, XMLHttpRequest technology is implemented on more sites now than ever. Compatibility is no longer an issue (IE, Mozilla and Opera all support it), and the benefits to using it are amazing. There are too many PHP programmers avoiding any
18
1965
omerbutt
by: omerbutt | last post by:
AJAX PROB WITH MULTIPLE RECORDS helo iam having problem in ma code will any body look out an help, i am trying t add sale record in the database and the checkthe quantity of the part slod and decrement it to the current quantity for example if tehre is a part woth part no 10023 and its quantity in show room is 20 and total quantity is 25 then if there is a sale of 2 parts then i have to add the sale and decrement the current quantity in the...
5
3853
by: BM | last post by:
I have a question that seems like it should have a simple answer, but I can't seem to find it by searching... Anyway, I'm trying to capture the IsPostBack event when I select an item within an UpdatePanel. I don't want items running during postback (list, grid population, etc) events - pretty standard: If IsPostBack Then Exit Sub But, since AJAX doesn't technically postback (?), the IsPostBack is coming back false...
8
2683
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a contact_us.php page.Now i can get all the inputs at the other end else the input(type/file) i donot want a submit button what i want that some how io can send the file name and the path of the picture that is to be uploaded and send to a page via ajax...
1
4595
by: javediq143 | last post by:
Hi All, This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in Database but I'm stuck in the EDIT. I'm getting 2 problems over here. Below is the description: 1)The FIRST page will list all the records from the table which Admin can EDIT with CHECKBOX for each record to select. He can select one or more than one...
5
2664
by: MelindaM | last post by:
Hi guys, I created a form for searching through a parts library that I have stored in a MySQL database. I'm not new to web programming but this is my first time using PHP and Ajax. I have four listboxes that are chained together. In other words, if you click on the first one it filters out what's available in the next three. If you click on the 3rd one, it filters out the available options in the 4th one, etc. I do this by having php pages...
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
7193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5574
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.