Nothing happens when I click the Checkboxes ON or OFF. When ON I should get a calculated price based on Qty & when OFF, I should get a zero price.
Can you tell me what’s wrong? I’ve checked over & over and I believe my code is according to JS documentation.
Various versions of my code indicate:
1 - When using parameter passing, the function doesn’t get called
2 - Without parameter passing & using only one IF and no ELSE, the routine will work although not very well – the checkbox value is always “yes” whether I click it on or off. As soon as I use an ELSE or ELSE IF, I get “Error on page”.
Code hereunder.
Thank you,
Michael
<html>
<head>
<title>Task Selection</title>
</head>
<a name="#Start"></a>
<script type="text/javascript">
function mycalc(mysel)
{
alert (mysel)
if mysel = "one"
{
if (document.getElementById('Benefits').value = "yes")
{document.getElementById("pr01").value = (225 * (document.getElementById('q01').value))}
else
{document.getElementById("pr01").value = 0}
}
else if mysel = "two"
{
if (document.getElementById('Visit').value = "yes")
{document.getElementById("pr02").value = (150 * (document.getElementById('q02').value))}
else
{document.getElementById("pr02").value = 0}
}
document.getElementById("total").value = (document.getElementById("pr01").value * 1) + (document.getElementById("pr02").value * 1)
}
</script>
<noscript>Your browser does not support JavaScript!</noscript>
<center><b>
<font color ="Blue" size=6>
TASKS SELECTION
</b></font>
<font color ="Blue" size=2><p align=left>
       
<font color ="Blue" size=2>Price
         
<font color ="Blue" size=2>Qty
        
<font color ="Blue" size=2>|Task Names (Click/Check the box of desired tasks.)
</font>
<font color="Black">
<br>
    
<input type="Number" size=7 id="pr01" value=0>
<input type="Number" size=2 id="q01" value=1>
<input name="Benefits" type="checkbox" onclick="mycalc("one")">
Accident Benefits Claim Form Package
<br>
    
<input type="Number" size=7 id="pr02" value=0>
<input type="Number" size=2 id="q02" value=1>
<input name="Visit" type="checkbox" onclick="mycalc("two")">
SABS-Visit with authorization
<br>
    
<input type="Number" size=7 id="total" value=0>
 
= Total Cost
</p></font>
</form>
</body>
</html>
Can you tell me what’s wrong? I’ve checked over & over and I believe my code is according to JS documentation.
Various versions of my code indicate:
1 - When using parameter passing, the function doesn’t get called
2 - Without parameter passing & using only one IF and no ELSE, the routine will work although not very well – the checkbox value is always “yes” whether I click it on or off. As soon as I use an ELSE or ELSE IF, I get “Error on page”.
Code hereunder.
Thank you,
Michael
<html>
<head>
<title>Task Selection</title>
</head>
<a name="#Start"></a>
<script type="text/javascript">
function mycalc(mysel)
{
alert (mysel)
if mysel = "one"
{
if (document.getElementById('Benefits').value = "yes")
{document.getElementById("pr01").value = (225 * (document.getElementById('q01').value))}
else
{document.getElementById("pr01").value = 0}
}
else if mysel = "two"
{
if (document.getElementById('Visit').value = "yes")
{document.getElementById("pr02").value = (150 * (document.getElementById('q02').value))}
else
{document.getElementById("pr02").value = 0}
}
document.getElementById("total").value = (document.getElementById("pr01").value * 1) + (document.getElementById("pr02").value * 1)
}
</script>
<noscript>Your browser does not support JavaScript!</noscript>
<center><b>
<font color ="Blue" size=6>
TASKS SELECTION
</b></font>
<font color ="Blue" size=2><p align=left>
       
<font color ="Blue" size=2>Price
         
<font color ="Blue" size=2>Qty
        
<font color ="Blue" size=2>|Task Names (Click/Check the box of desired tasks.)
</font>
<font color="Black">
<br>
    
<input type="Number" size=7 id="pr01" value=0>
<input type="Number" size=2 id="q01" value=1>
<input name="Benefits" type="checkbox" onclick="mycalc("one")">
Accident Benefits Claim Form Package
<br>
    
<input type="Number" size=7 id="pr02" value=0>
<input type="Number" size=2 id="q02" value=1>
<input name="Visit" type="checkbox" onclick="mycalc("two")">
SABS-Visit with authorization
<br>
    
<input type="Number" size=7 id="total" value=0>
 
= Total Cost
</p></font>
</form>
</body>
</html>