I want to call a function that adds values from two separate functions. the functions produce values in a drop down box. For example function one outputs dropdon value in a text field box and function two outputs another value .
I want to call a function that adds the values of the two drop down boxes. The code for each dropdown is in a separate function.
My problem is adding the values from the two dropdown boxes.
Here is my code
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
var dropdown1,field,dropdown2,result;
function Foodplace()
{
dropdown1 = document.getElementById("ifastfood");
field = document.getElementById("ifastfoodName");
field.value = dropdown1.value;
}
function PopulateUserName2()
{
dropdown2 = document.getElementById("ifastfood2");
field = document.getElementById("ifastfoodName2");
field.value = dropdown2.value;
}
function calculate(){
result=dropdown1.value+dropdown2.value;
document.write("result");
}
</script>
</head>
<body>
<select name="nfastfood" id="ifastfood" onchange="Foodplace()">
<option value=>Select an item </option>
<option value=8.95>potato roti </option>
<option value=9.95>Beef roti</option>
</select>
<input id="ifastfoodName" name="OBKey_WF_Manger_Supervisor_1" type="text" />
<br><br>
<select name="nfastfood2" id="ifastfood2" onchange="PopulateUserName2()">
<option value=>Select an item </option>
<option value=11.56>Bran Burger </option>
<option value=12.33>Burger with cheese</option>
</select>
<input id="ifastfoodName2" name="OBKey_WF_Manger_Supervisor_1" type="text" />
<br><br>
<button onclick="add()">Calculate</button>
</body>
</html>
I want to call a function that adds the values of the two drop down boxes. The code for each dropdown is in a separate function.
My problem is adding the values from the two dropdown boxes.
Here is my code
<!DOCTYPE HTML>
<html>
<head>
<title>Untitled</title>
<script type="text/javascript">
var dropdown1,field,dropdown2,result;
function Foodplace()
{
dropdown1 = document.getElementById("ifastfood");
field = document.getElementById("ifastfoodName");
field.value = dropdown1.value;
}
function PopulateUserName2()
{
dropdown2 = document.getElementById("ifastfood2");
field = document.getElementById("ifastfoodName2");
field.value = dropdown2.value;
}
function calculate(){
result=dropdown1.value+dropdown2.value;
document.write("result");
}
</script>
</head>
<body>
<select name="nfastfood" id="ifastfood" onchange="Foodplace()">
<option value=>Select an item </option>
<option value=8.95>potato roti </option>
<option value=9.95>Beef roti</option>
</select>
<input id="ifastfoodName" name="OBKey_WF_Manger_Supervisor_1" type="text" />
<br><br>
<select name="nfastfood2" id="ifastfood2" onchange="PopulateUserName2()">
<option value=>Select an item </option>
<option value=11.56>Bran Burger </option>
<option value=12.33>Burger with cheese</option>
</select>
<input id="ifastfoodName2" name="OBKey_WF_Manger_Supervisor_1" type="text" />
<br><br>
<button onclick="add()">Calculate</button>
</body>
</html>