Setup: I have a drop downbox that has sizes in it. Hidden input fields that declare prices for the different sizes. I have a script that when the dropdown box is changed it goes through and assigns the prices = to what was chosen in the dropdown box.
Here is the script I use.
function computeprice()
{
var f = document.forms[0]
var newprice
if (f.sizeselector[f.sizeselector.selectedIndex].value == 3)
{newprice = f.tprice1.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
else if(f.sizeselector[f.sizeselector.selectedIndex].value == 4)
{newprice = f.tprice2.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
else if(f.sizeselector[f.sizeselector.selectedIndex].value == 5)
{newprice = f.tprice3.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
else
{newprice = f.tprice.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
}
The problem is I can't get the script to identify what was chosen in the dropdown box correctly. I either stops on the first If statement or passes all of them up. I believe that it has something to do with how I am telling the script what to look for. I am not sure where to go from here. Does any one have any ideas?
Ken [sig][/sig]
Here is the script I use.
function computeprice()
{
var f = document.forms[0]
var newprice
if (f.sizeselector[f.sizeselector.selectedIndex].value == 3)
{newprice = f.tprice1.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
else if(f.sizeselector[f.sizeselector.selectedIndex].value == 4)
{newprice = f.tprice2.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
else if(f.sizeselector[f.sizeselector.selectedIndex].value == 5)
{newprice = f.tprice3.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
else
{newprice = f.tprice.value;
f.showsizeselection.value = f.sizeselector.selectedIndex;
f.showprice.value = newprice;
}
}
The problem is I can't get the script to identify what was chosen in the dropdown box correctly. I either stops on the first If statement or passes all of them up. I believe that it has something to do with how I am telling the script what to look for. I am not sure where to go from here. Does any one have any ideas?
Ken [sig][/sig]