0
<body>
<form method="post" action="script name"><font color= white>
<b>Check Your Favorite Pass Times:</b><br>
<input type="checkbox" value="TV" onClick="validate(this)"name = 'n1'>Watching TV<br>
<input type="checkbox" value="Hiking" onClick="validate(this)" name='n2'>Hiking<br>
<input type="checkbox" value="Surfing" onClick="validate(this)" name='n3'>Surfing the net.<br>
<input type="checkbox" value="Building" onClick="validate(this)"name='n4'>Building Web Pages.<br>
<input type="checkbox" value="Reading" onClick="validate(this)"name='n5'>Reading a book.<br>
<input type="reset" value="Reset"><br>
<input type="submit" value="compute"><br>
<?php
if(chk.checked ==$_POST['n1']) {

pVal+=10
if(pVal > 100) pVal = 100
percent.innerHTML=pVal + "%"
}else {
pVal-=20
if(pVal < 0) pVal = 0
percent.innerHTML=pVal + "%"

}
?>

</font>
</form>
<div id="percent">0%</div>
</body>
</html>

each of the check boxes are evenly distributed by 20 what I want now is to change the values of each check boxes unevenly
the problem is when I got to the computation since not all users check all the boxes I want to compute the checked check boxes

I know this is possible to do but I dunno to do it

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by masterjiraya
0

make one of your check box as selected by default and apply javascript check that one check box must be selected, may be in this way your problem will resolve

0

make one of your check box as selected by default and apply javascript check that one check box must be selected, may be in this way your problem will resolve

this is the script language of java

<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>

I dunno how to set the default for chkbox

how to revise the code in my desired target???

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.