rtnMichael
Programmer
Hey, I want to populate a drop down, not through a DB, but from an array through a variable chosen from the previous page. I know how to do it when it's on the same page with an array, but I'm having trouble getting it to run on another page.
Here's what I have when it's on the same page:
team = new Array(
new Array(
new Array("door","door"
,
new Array("window","window"
,
new Array("carpet","carpet"
),
new Array(
new Array("brown","brown"
,
new Array("red","red"
,
new Array("blue","blue"
),
new Array(
new Array("house","house"
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var x, j;
var prompt;
// empty existing items
for (x = selectCtrl.options.length; x >= 0; x--) {
selectCtrl.options[x] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (x = 0; x < itemArray.length; x++) {
selectCtrl.options[j] = new Option(itemArray[x][0]);
if (itemArray[x][1] != null) {
selectCtrl.options[j].value = itemArray[x][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
Select Option <SELECT NAME="option" size=1 onchange="fillSelectFromArray(this.form.gotoption, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));">
<option selected value='-1'>Select Option...</option>
<option value = 'Option1'>Option1</option>
<option value = 'Option2'>Option2</option>
<option value = 'Option3'>Option3</option>
</select>
<TD><SELECT NAME="gotoption" SIZE="1">
<OPTION selected value='-1'>None</OPTION>
<OPTION> </OPTION>
<OPTION> </OPTION>
</SELECT>
So Option1 gives me:
door
window
carpet
I just want to get the drop down to populate in the next page. How would I do that???
Thanks
Mike
Here's what I have when it's on the same page:
team = new Array(
new Array(
new Array("door","door"
new Array("window","window"
new Array("carpet","carpet"
),
new Array(
new Array("brown","brown"
new Array("red","red"
new Array("blue","blue"
),
new Array(
new Array("house","house"
)
);
function fillSelectFromArray(selectCtrl, itemArray, goodPrompt, badPrompt, defaultItem) {
var x, j;
var prompt;
// empty existing items
for (x = selectCtrl.options.length; x >= 0; x--) {
selectCtrl.options[x] = null;
}
prompt = (itemArray != null) ? goodPrompt : badPrompt;
if (prompt == null) {
j = 0;
}
else {
selectCtrl.options[0] = new Option(prompt);
j = 1;
}
if (itemArray != null) {
// add new items
for (x = 0; x < itemArray.length; x++) {
selectCtrl.options[j] = new Option(itemArray[x][0]);
if (itemArray[x][1] != null) {
selectCtrl.options[j].value = itemArray[x][1];
}
j++;
}
// select first item (prompt) for sub list
selectCtrl.options[0].selected = true;
}
}
Select Option <SELECT NAME="option" size=1 onchange="fillSelectFromArray(this.form.gotoption, ((this.selectedIndex == -1) ? null : team[this.selectedIndex-1]));">
<option selected value='-1'>Select Option...</option>
<option value = 'Option1'>Option1</option>
<option value = 'Option2'>Option2</option>
<option value = 'Option3'>Option3</option>
</select>
<TD><SELECT NAME="gotoption" SIZE="1">
<OPTION selected value='-1'>None</OPTION>
<OPTION> </OPTION>
<OPTION> </OPTION>
</SELECT>
So Option1 gives me:
door
window
carpet
I just want to get the drop down to populate in the next page. How would I do that???
Thanks
Mike