Brug DEL 1, hvis du har mere end 1 (een) checkbox eller
Brug DEL 2, hvis du kun har 1 (een) checkbox.
Brug DISABLED, hvis knappen skal være inaktiv (=grå) eller
Brug VISIBILITY, hvis knappen skal forsvinde.
<html><head><script>
/*** [b]DEL 1, start[/b] ***/
var count = 0;
/*** [b]DEL 1, slut[/b] ***/
function toggleSubmit(cb) {
/*** [b]DEL 1, start[/b] ***/
if(cb.checked) {
count++;
// [b]DISABLED[/b]
submitbutton.disabled = false;
// [b]VISIBILITY[/b]
submitbutton.style.visibility = "visible";
}
else
if(--count==0) {
// [b]DISABLED[/b]
submitbutton.disabled = true;
// [b]VISIBILITY[/b]
submitbutton.style.visibility = "hidden";
}
/*** [b]DEL 1, slut[/b] ***/
/*** [b]DEL 2, start[/b] ***/
// [b]DISABLED[/b]
submitbutton.disabled = !cb.checked;
// [b]VISIBILITY[/b]
submitbutton.style.visibility = (cb.checked)?"visible":"hidden";
/*** [b]DEL 2, slut[/b] ***/
}
function init() {
submitbutton = document.getElementById("SUBMITBUTTON");
/*** [b]DEL 1 og i DEL 2, start[/b] ***/
// [b]DISABLED[/b]
submitbutton.disabled = true;
// [b]VISIBILITY[/b]
submitbutton.style.visibility = "hidden";
/*** [b]DEL 1 og i DEL 2, slut[/b] ***/
}
</script></head><body onload="init()">
<input type="checkbox" onclick="toggleSubmit(this)" />
<input type="checkbox" onclick="toggleSubmit(this)" />
<input id="SUBMITBUTTON" type="submit" value="Submit" />
</body></html>