I have a set of checkbox which has different values depending on the combination of selected boxes, but the code I made didn't work, I was thinking maybe the location of my && sign is not in proper position but I don't know where exactly I can put it to run the code.
Here is the html code:
<form role="form" id="checkbox" name="checkbox" onclick="changevalue()">
<input type="checkbox" id="f1">Full Front
<input type="checkbox" id="b1">Full Back
<input type="checkbox" id="f2">Pocket
</form>
<input type="number" id="checkboxResult">
And here is the script:
<script type="text/javascript">
function changevalue(form){
var chkboxvalue = 0;
if (document.getElementById('f1').checked) &&
if (document.getElementById('b1').checked) {
chkboxvalue = 2.2;
};
if (document.getElementById('f2').checked) &&
if (document.getElementById('b1').checked) {
chkboxvalue = 1.7;
};
document.getElementById('checkboxResult').value = chkboxvalue;
}
</script>
Aucun commentaire:
Enregistrer un commentaire