Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > ajax multiple select php

Reply
Thread Tools

ajax multiple select php

 
 
trpost@gmail.com
Guest
Posts: n/a
 
      02-12-2007
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

 
Reply With Quote
 
 
 
 
Darko
Guest
Posts: n/a
 
      02-14-2007
On Feb 13, 12:52 am, (E-Mail Removed) 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 <select> object, empty it and fill it
with results. If nothing is fine then find the <select> object
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
FREE SEMINAR on PHP Web Development in Lahore, It covers PHP, MySQL,AJAX & Zend Certification EVS MCSE 0 08-08-2010 12:41 PM
FREE SEMINAR on PHP Web Development in Lahore and Rawalpindi, Itcovers PHP, MySQL, AJAX & Zend Certification EVS MCSE 0 05-31-2010 01:13 PM
PHP Training Institute In Delhi, Live Projects on PHP. Short TermPHP Courses, PHP Scripts, PHP Training with Live Projects. Rajive Narain Java 0 09-18-2009 10:47 AM
AJAX IDE and AJAX TOOL--The Release of JoyiStar AJAX WebShop 3 Beta minnie Java 1 12-13-2006 06:29 AM
select of select box will select multiple in another box palmiere Javascript 1 02-09-2004 01:11 PM



Advertisments