How to control multiple ajax return

F

Feijó

I have several combobox (select) witch when a User choose a value in
the first combo, it triggers an Ajax to feed the second combo. When
the second combo got its values, another Ajax feed my third combo, and
so one.

Its about 5 combos.

Ajax is not syncronous, can't be

My ajax return a new <select> <option> set

Thanks for any tip!


Here is what I'm trying:


var ie = (/msie/i.test(navigator.userAgent));
var tempo = 150;

function SelectCombo1() {
if (debug) document.getElementById('debugnc').innerHTML = Date() + '
nc<br>';

// I need to disapear with my combo or the next function will not work
if (!ie) // ie sucks
document.form1.Combo1=undefined;
else if (typeof !document.form1.Combo1 == 'undefined')
document.form1.Combo1.destroy();

var param = (document.form1.Combo1.value);

loadXMLDoc('combo.php?ajax=1&cod='+param, 'combo1', 'lista');
setTimeout("SelectCombo2();", tempo);
}

function SelectCombo2() {
if (typeof document.form1.Combo1 == 'undefined')
// wait until Combo1 is done
setTimeout("SelectCombo();", tempo);
else {
if (!ie)
document.form1.Combo2=undefined;
else if (typeof !document.form1.Combo2 == 'undefined')
document.form1.Combo2.destroy();

loadXMLDoc(str, 'combo2, 'lista');
setTimeout("SelectCombo3();", tempo);
}
}
 
G

GArlington

I have several combobox (select) witch when a User choose a value in
the first combo, it triggers an Ajax to feed the second combo. When
the second combo got its values, another Ajax feed my third combo, and
so one.

Its about 5 combos.

Ajax is not syncronous, can't be

My ajax return a new <select> <option> set

Thanks for any tip!

Here is what I'm trying:

var ie = (/msie/i.test(navigator.userAgent));
var tempo = 150;

function SelectCombo1() {
if (debug) document.getElementById('debugnc').innerHTML = Date() + '
nc<br>';

// I need to disapear with my combo or the next function will not work
if (!ie) // ie sucks
document.form1.Combo1=undefined;
else if (typeof !document.form1.Combo1 == 'undefined')
document.form1.Combo1.destroy();

var param = (document.form1.Combo1.value);

loadXMLDoc('combo.php?ajax=1&cod='+param, 'combo1', 'lista');
setTimeout("SelectCombo2();", tempo);

}

function SelectCombo2() {
if (typeof document.form1.Combo1 == 'undefined')
// wait until Combo1 is done
setTimeout("SelectCombo();", tempo);
else {
if (!ie)
document.form1.Combo2=undefined;
else if (typeof !document.form1.Combo2 == 'undefined')
document.form1.Combo2.destroy();

loadXMLDoc(str, 'combo2, 'lista');
setTimeout("SelectCombo3();", tempo);
}

}

You should read about how to use ajax: http://www.w3schools.com/ajax/default.asp
is always a good start.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top