Aha, very well. This makes sense.
Ickyb0d: If there are more than one set of buttons, this could be problematical.
Code:
<script type="text/javascript">
function checkDepends(element) {
for(var i=0;i<element.form.elements.length;i++)
if(element.form.elements[i].className.indexOf("depends-" + element.name) != -1)
element.form.elements[i].disabled = element.checked;
else if(element.form.elements[i].className.indexOf("conflicts-" + element.name) != -1)
element.form.elements[i].disabled = !element.checked;
}
</script>
<!-- This should allow you to create a form like this: -->
<form action="f.php" method="post">
<input type="checkbox" name="linux" class="conflicts-windows">
<input type="checkbox" name="ssh" class="depends-linux">
<input type="checkbox" name="cpanel" class="depends-linux">
<input type="checkbox" onclick="checkDepends(this);" name="windows" class="conflicts-linux">
<input type="checkbox" name="aspdotnet" class="depends-windows">
<input type="text" name="netbiosname" class="depends-windows">
</form>
Untested, but should work. Remember that it isn't a secure solution, and must be used in tandem with a server-side check.
Bookmarks