I’m trying to get the value from the selected option in a drop down and multiply it by another. The values of this particular drop down are numbers, but I keep getting NaN.
This is the form:
<select size=”1″ name=”number” tabindex=”4″>
<option value=”1″ selected=”selected”>Choose Number</option>
<option value=”1″>1</option>
<option value=”2″>2</option>
</select>
Here’s the script I’m trying to use:
function calcTotal5(){
var seating = document.FrontPage_Form1.price.value;
var subscriptions = document.FrontPage_Form1.number.value; // problem is here
var calculate = seating * subscriptions;
document.FrontPage_Form1.TOTAL.value = calculate;
}
I also tried this:
var subscriptions = document.FrontPage_Form1.number.options[document.FrontPage_Form1.number.selectedIndex].value;
I’m much more at home with PHP, but have to use javascript for this. The problematic line is the one I commented on. If I comment that entire line out and where the multiply is, replace subscriptions with an integer, it works fine. I’m just not grabbing the value from the drop down ‘number’ correctly. When I get the value of subscriptions, it’s ‘undefined’.
Any help would be appreciated, thank you