F
Flic
Hi,
I made a page with two drop boxes in, with the aim of repeating a lot
of times. I set it up so that instead of repeating the options for
each box they would be filled in when the page was loaded. The two
boxes worked fine with that and a number of other functions they
performed but now I've come to duplicate them and I've hit a problem.
I have named each drop down box consecutively (sp?) and have a while
loop to fill them but its not working.
Please see the code below:
function load(){
var i = 0;
while (i <= 10) {
var selcat = ("category" + i);
var selpri = ("price" + i);
var selnam = ("name" + i);
document.order.selpri.value = "";
document.order.selcat[0] = new Option("Please select...", "cat",
true);
document.order.selcat[1] = new Option("Accessories", "acc", false);
document.order.selcat[2] = new Option("Bolted Silo", "bol", false);
document.order.selcat[3] = new Option("Welded Silo", "wel", false);
document.order.selcat[4] = new Option("Horizontal Silo", "hor",
false);
document.order.selnam[0] = new Option("Please select a category...",
"cat", false);
i++;
} }
Am I being really silly and missing something obvious? I tried using
getElementById but that didn't work, I'm thinking because technically
its not the id.
Any help would be much appreciated! Thanks
I made a page with two drop boxes in, with the aim of repeating a lot
of times. I set it up so that instead of repeating the options for
each box they would be filled in when the page was loaded. The two
boxes worked fine with that and a number of other functions they
performed but now I've come to duplicate them and I've hit a problem.
I have named each drop down box consecutively (sp?) and have a while
loop to fill them but its not working.
Please see the code below:
function load(){
var i = 0;
while (i <= 10) {
var selcat = ("category" + i);
var selpri = ("price" + i);
var selnam = ("name" + i);
document.order.selpri.value = "";
document.order.selcat[0] = new Option("Please select...", "cat",
true);
document.order.selcat[1] = new Option("Accessories", "acc", false);
document.order.selcat[2] = new Option("Bolted Silo", "bol", false);
document.order.selcat[3] = new Option("Welded Silo", "wel", false);
document.order.selcat[4] = new Option("Horizontal Silo", "hor",
false);
document.order.selnam[0] = new Option("Please select a category...",
"cat", false);
i++;
} }
Am I being really silly and missing something obvious? I tried using
getElementById but that didn't work, I'm thinking because technically
its not the id.
Any help would be much appreciated! Thanks