ASP/MySql database into JavaScript Array
what i am trying to do is create a Dynamically linked pair of ComboBoxes. State/City to be exact. you click on the state ComboBoxand select say california and you get say San Diego in the City ComboBox. i have everything worked out except how to set up my asp database connection to work with this javascript code.
function populatecombo(elem, index, array){
if (array.length >= index){
if (array[index]){
for (var i = 0; i < array[index].length; i= i + 2){
elem.options[elem.options.length] = new Option(array[index][i + 1], array[index][i]);
}
}
else{
elem.options[elem.options.length] = new Option("[none available]", 0);
}
}
else{
elem.options[elem.options.length] = new Option("[none available]", 0);
}
}
i already have a function that clears the combo box of its selections and my database is set up so that it has one table with the ID, StateID, StateName and CityName.
the sql statement selects all info from the table and fills the state ComboBox using seperate asp code. then i have the state ComboBox onChange event handler call the script to clear the city box, then repopulate the city box using the "populatecombo" script. nothing happens so far because i dont know how to transfer information from either a recordset table or an array in asp into javascript. the only thing i have been able to come up with would be to use an asp loop to write the javascript. i am trying to avoid this since i know very little javascript.
any help would be appreciated
-----------------------------------------
Inigo: You have a great gift for rhyme.
Fezzik: Yes, yes, some of the time.
Vizzini: Enough of that.
Inigo: Fezzik, are there rocks ahead?
Fezzik: If there are, we'll all be dead.
Vizzini: No more rhymes now, I mean it!
Fezzik: Anybody want a peanut?
__________________
-----------------------------------------
Inigo: You have a great gift for rhyme.
Fezzik: Yes, yes, some of the time.
Vizzini: Enough of that.
Inigo: Fezzik, are there rocks ahead?
Fezzik: If there are, we\'ll all be dead.
Vizzini: No more rhymes now, I mean it!
Fezzik: Anybody want a peanut?
|