473,324 Members | 2,254 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

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 8183
On Feb 13, 12:52 am, trp...@gmail.com 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 getAJAXXMLHandler()
{
var xmlHttp = null;
try {
if (window.XMLHttpRequest) { // Mozilla, Safari,...
xmlHttp = new XMLHttpRequest();

if (xmlHttp.overrideMimeType)
xmlHttp.overrideMimeType('text/xml');
else
xmlHttp = null;
} else if (window.ActiveXObject) { // IE
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} 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.responseXML;
and then
var documentRoot = xmlDocument.documentElement;
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
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...
10
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...
1
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...
1
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...
18
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...
5
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...
8
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...
1
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...
5
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...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.