I have a javascript problem. I’m using radio buttons to hold values and based on when a user clicks on a radio button, it will add the price to a read only text box.
The problem I’m facing is trying to convert the whole number to a decimal. It started off in the database as a decimal and now when using asp to add to javascript, it displays as a whole number. How do I convert it back? I’ve tried to use the parseDouble function but it will not work, unless I’m not using it right. Here’s my code and I thank you before hand for helping:
WriteLn(“<script language=JavaScript src=/includes/functions.js></script>”)
WriteLn(“<script language=JavaScript>”)
WriteLn(“<!–“)
WriteLn(“function CalculateTotal() {“)
WriteLn(“if(document.main.subYear[0].checked && document.main.SAME_ADDRESS.value == ‘Y’) {“)
WriteLn(“document.main.TOTAL.value =” & DEFAULT1)
WriteLn(“} else if(document.main.subYear[0].checked && document.main.SAME_ADDRESS.value != ‘Y’ && document.main.SHIP_COUNTRY.value == ‘US’) {“)
WriteLn(“document.main.TOTAL.value =” & CDbl(DEFAULT1))
WriteLn(“} else if(document.main.subYear[0].checked && document.main.SAME_ADDRESS.value != ‘Y’ && document.main.SHIP_COUNTRY.value != ‘US’) {“)
WriteLn(“document.main.TOTAL.value =” & totalParam3)
WriteLn(“} else if(document.main.subYear[1].checked && document.main.SAME_ADDRESS.value == ‘Y’) {“)
WriteLn(“document.main.TOTAL.value =” & CDbl(DEFAULT2))
WriteLn(“} else if(document.main.subYear[1].checked && document.main.SAME_ADDRESS.value != ‘Y’ && document.main.SHIP_COUNTRY.value == ‘US’) {“)
WriteLn(“document.main.TOTAL.value =” & CDbl(DEFAULT2))
WriteLn(“} else if(document.main.subYear[1].checked && document.main.SAME_ADDRESS.value != ‘Y’ && document.main.SHIP_COUNTRY.value != ‘US’) {“)
WriteLn(“document.main.TOTAL.value =” & totalParam4)
WriteLn(“} else if(document.main.subYear[2].checked && document.main.SAME_ADDRESS.value == ‘Y’) {“)
WriteLn(“document.main.TOTAL.value =” & CDbl(DEFAULT3))
WriteLn(“} else if(document.main.subYear[2].checked && document.main.SAME_ADDRESS.value != ‘Y’ && document.main.SHIP_COUNTRY.value == ‘US’) {“)
WriteLn(“document.main.TOTAL.value =” & CDbl(DEFAULT3))
WriteLn(“} else if(document.main.subYear[2].checked && document.main.SAME_ADDRESS.value != ‘Y’ && document.main.SHIP_COUNTRY.value != ‘US’) {“)
WriteLn(“document.main.TOTAL.value =” & totalParam5)
WriteLn(“}}”)