Glaanieboy
OSNN Veteran Addict
- Joined
- 6 Mar 2002
- Messages
- 2,628
Code:
<script type="text/javascript">
function checkForm(){
if (document.bestelformulier.ingredient[3].value == '1'){
alert('U dient wel een keus te maken!');
}else{
document.bestelformulier.submit.disabled = true;
return true;
}
}
</script>
Stel zelf een pizza samen<br>
<form action="zelf.php?action=zelf" method="POST" onSubmit="javascript:checkForm();" name="bestelformulier">
<table>
<tr><td><input type="checkbox" name="ingredient[3]" value="1"></td><td>ui</td><td>€ 0.70</td></tr>
<tr><td><input type="checkbox" name="ingredient[2]" value="1"></td><td>tomaat</td><td>€ 0.60</td></tr>
<tr><td><input type="checkbox" name="ingredient[1]" value="1"></td><td>Kaas</td><td>€ 0.50</td></tr>
<tr><td><input type="checkbox" name="ingredient[4]" value="1"></td><td>champions</td><td>€ 0.80</td></tr>
</table>
Opmerkingen bij bestelling:<br>
<textarea rows="15" cols="40" name="opmerking"></textarea>
<input type="submit" value="OK" name="submit">
</form>
Have a look at this code. This code should do two things:
- First check if at least one checkbox is checked.
- Then set the OK button to disabled, so users can't click it again
First point: How do I do that? As a test, I have set it up in a way, so that it checks the value of ingredient[3], if checked, warning, if not, continue. But it doesn't do that, why? And how to set it up? That brings me to the second point, how to check if at least one checkbox is checked?
Third point: The grey-out thingy worked perfect when it was in the onSubmit="" quotes, but now that I have put it in a form, it doesn't work.
Help me!