<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

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

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.