R
Radwan G
Guest
Hi
I have the code bellow that it gives each checkbox that is checked a 20% value.
How would I go about changing the value for each box, say checkbox 1 with a 13% value, checkbox 2 with 27% value, checkbox 3 with a 50% value, checkbox 4 with a 6% value and checkbox 5 with a 4% value???
any help is greatly appreciated
<html>
<head>
<title></title>
<script language="javascript">
var pVal=0
function validate(chk) {
if(chk.checked == 1) {
document.body.style.background
="green"
pVal+=20
if(pVal > 100) pVal = 100
percent.innerHTML=pVal + "%"
}
else {
pVal-=20
if(pVal < 0) pVal = 0
percent.innerHTML=pVal + "%"
}
}
</script>
</head>
<body>
<form method="post" action="script name">
<b>Check Your Favorite Pass Times:</b><br>
<input type="checkbox" value="TV" onClick="validate(this)">Watching TV<br>
<input type="checkbox" value="Hiking" onClick="validate(this)">Hiking<br>
<input type="checkbox" value="Surfing" onClick="validate(this)">Surfing the net.<br>
<input type="checkbox" value="Building" onClick="validate(this)">Building Web Pages.<br>
<input type="checkbox" value="Reading" onClick="validate(this)">Reading a book.<br>
<input type="reset" value="Reset"><br>
</form>
<div id="percent">0%</div>
</body>
</html>
I have the code bellow that it gives each checkbox that is checked a 20% value.
How would I go about changing the value for each box, say checkbox 1 with a 13% value, checkbox 2 with 27% value, checkbox 3 with a 50% value, checkbox 4 with a 6% value and checkbox 5 with a 4% value???
any help is greatly appreciated
<html>
<head>
<title></title>
<script language="javascript">
var pVal=0
function validate(chk) {
if(chk.checked == 1) {
document.body.style.background
="green"
pVal+=20
if(pVal > 100) pVal = 100
percent.innerHTML=pVal + "%"
}
else {
pVal-=20
if(pVal < 0) pVal = 0
percent.innerHTML=pVal + "%"
}
}
</script>
</head>
<body>
<form method="post" action="script name">
<b>Check Your Favorite Pass Times:</b><br>
<input type="checkbox" value="TV" onClick="validate(this)">Watching TV<br>
<input type="checkbox" value="Hiking" onClick="validate(this)">Hiking<br>
<input type="checkbox" value="Surfing" onClick="validate(this)">Surfing the net.<br>
<input type="checkbox" value="Building" onClick="validate(this)">Building Web Pages.<br>
<input type="checkbox" value="Reading" onClick="validate(this)">Reading a book.<br>
<input type="reset" value="Reset"><br>
</form>
<div id="percent">0%</div>
</body>
</html>