J
John
Hi all,
I would welcome any assistance with this problem.
I have an Input Textbox named 'givendiscount'
I have a drop down box named 'd1'
I have an Input Textbox named 'subtotalvalue'
I have an Input Textbox named 'discountvalue'
I have an Input Textbox named 'totalcostvalue'
What should happen is that a user enters a discount amount in 'givendiscount'
He/She then chooses an option from 'd1'
After clicking a button (the code says onClick="calculatecost()") then three values should be
entered into the boxes.
Here is the function...
<script language="javascript">
function calculatecost() {
var totalcost,discount,subtotal,ind;
discount=+(document.forms[0].givendiscount.value);
ind=+(document.forms[0].d1.options.selectedIndex);
subtotal=+(document.forms[0].d1.options.[ind].value);
totalcost=subtotal-(subtotal/discount};
document.forms[0].subtotalvalue.value=subtotal;
document.forms[0].discountvalue.value=discount;
document.forms[0].totalcostvalue.value=totalcost.toFixed(2);
}
</script>
The code is in the HEAD section of the page.
Trouble is, nothing is happening at all...not even any error codes.
Can anyone help please.
TIA.
I would welcome any assistance with this problem.
I have an Input Textbox named 'givendiscount'
I have a drop down box named 'd1'
I have an Input Textbox named 'subtotalvalue'
I have an Input Textbox named 'discountvalue'
I have an Input Textbox named 'totalcostvalue'
What should happen is that a user enters a discount amount in 'givendiscount'
He/She then chooses an option from 'd1'
After clicking a button (the code says onClick="calculatecost()") then three values should be
entered into the boxes.
Here is the function...
<script language="javascript">
function calculatecost() {
var totalcost,discount,subtotal,ind;
discount=+(document.forms[0].givendiscount.value);
ind=+(document.forms[0].d1.options.selectedIndex);
subtotal=+(document.forms[0].d1.options.[ind].value);
totalcost=subtotal-(subtotal/discount};
document.forms[0].subtotalvalue.value=subtotal;
document.forms[0].discountvalue.value=discount;
document.forms[0].totalcostvalue.value=totalcost.toFixed(2);
}
</script>
The code is in the HEAD section of the page.
Trouble is, nothing is happening at all...not even any error codes.
Can anyone help please.
TIA.