Right so i have values in 3 dropdown boxes and there will be more (looking at adding about 20 dropdown boxes that add to give a final price for the item. Here is the code for the HTML.
<form id="myform1>
<p>Testing 1</p>
<select id="Test1">
<option value="24">Item one</option>
<option value="29">Item Two<option>
<!--I have the first box going to 20 items-->
</select>
<p>Testing 2</p>
<select id="Test2">
<option value="25">Item one</option>
<option value="100">Item Two<option>
<!--I have the second box going to 10 items-->
</select>
<p>Testing 3</p>
<select id="Test3">
<option value="24">Item one</option>
<option value="100">Item Two<option>
<!--I have the third box going to 10 items-->
</select>
</form>
<button onclick="myFunction()">Update</button>
<p id="demo"></p>
Then i have my Javascript
function myFunction()
{
var a = document.getElementById("list1");
var A = a.options[a.selectedIndex].value;
var b = document.getElementById("list2");
var B = b.options[a.selectedIndex].value;
var c = document.getElementById("list3");
var C = c.options[a.selectedIndex].value;
var IntA = parseInt(A);
var IntB = parseInt(B);
var IntC = parseInt(C);
var x=IntB + IntA;
var y=x + IntC;
var demoP=document.getElementById("demo")
demoP.innerHTML= y;
}
My Problem is it only works if i take var c our completely and then take var y out and have it calculate to x. I have tryed many ways and am at a loss. Cheers
P.S. Java script is in a script tag at the bottom