jmoore2141
Programmer
I'm using ajax to return an array based on a value selected from list box1. The objective is then to clear listbox2 and repopulate with the array. I am successfully returning the php array and storing as a javascript variable and than clearing listbox 2. In the next step I'm loading the list box. The problem is I'm unable to strip out the php array structure. Any ideas on how to approach this would be appreciated.
options in list box look like:
array(2){[0]=> string(14)
Some Value1
[1]=>string(21)
Some Value2
[2]=>string(21).....
The array being passed into script looks like:
array(2){
[0]=>
string(14)"SomeValue1"
[1]=>
string(21)"SomeValue2"
}
Current code to re-populate listbox
// Repopulate the list box
var selbox = document.Form1.customer;
var al = content;
var alsplit = al.split('"');
for(i=0;i<alsplit.length;i++) {
var sa=alsplit.split('"');
var2 = new Option(sa[0]);
selbox.options[selbox.options.length] = var2;
}
alert(content);
}
Thanks,
Josh
options in list box look like:
array(2){[0]=> string(14)
Some Value1
[1]=>string(21)
Some Value2
[2]=>string(21).....
The array being passed into script looks like:
array(2){
[0]=>
string(14)"SomeValue1"
[1]=>
string(21)"SomeValue2"
}
Current code to re-populate listbox
// Repopulate the list box
var selbox = document.Form1.customer;
var al = content;
var alsplit = al.split('"');
for(i=0;i<alsplit.length;i++) {
var sa=alsplit.split('"');
var2 = new Option(sa[0]);
selbox.options[selbox.options.length] = var2;
}
alert(content);
}
Thanks,
Josh