Hi all,
Please forgive me if I have missed something glaringly obvious...
I am attempting to create a form that can calculate totals base on user selections in a form. The actual form that is to be calculated is more complex than the one below as I have quickly written this as a test. For some reason it is not completing as intended and I just cant see where the error is... Im not sure if it is just because I have reached the end of my tether!
The HTML:
The JS:
Again, its probably something pathetic lol but I would appreciate a fresh pair of eyes...
Thanks in advance,
Adam.
Please forgive me if I have missed something glaringly obvious...
I am attempting to create a form that can calculate totals base on user selections in a form. The actual form that is to be calculated is more complex than the one below as I have quickly written this as a test. For some reason it is not completing as intended and I just cant see where the error is... Im not sure if it is just because I have reached the end of my tether!
The HTML:
HTML:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
<script type="text/javascript" src="testjs.js"></script>
</head>
<body onLoad="hideTotal()">
<div id="container">
<form method="post" id="formID">
<fieldset>
<select name="dropName" id="dropID" form="formID" title="dropTitle" onChange="calculateTotal()">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
</select>
</fieldset>
<div id="totalDIV"></div>
</form>
</div>
</body>
</html>
JavaScript:
var dropOptions new Array;
dropOptions["1"]=10;
dropOptions["2"]=20;
function getdropOptions()
{
var dropOptionsValue=0;
var theForm = document.forms["formID"];
var selecteddropOptions = theForm.elements["dropID"];
dropOptionsValue = dropOptions[selecteddropOptions.Value];
return dropOptionsValue;
}
function calculateTotal()
{
var overallTotal = getdropOptions();
var divobj = document.getElementById('totalDIV');
divobj.style.display='block';
divobj.innerHTML = "Total Price For the Cake $"+overallTotal;
}
function hideTotal()
{
var divobj = document.getElementById('totalDIV');
divobj.style.display='none';
}
Again, its probably something pathetic lol but I would appreciate a fresh pair of eyes...
Thanks in advance,
Adam.