Stijn Goris wrote:
foto toevoegen? <input name="fotoToevoegen" type="checkbox" value="1"
ondelect="EnableInput(this.form);"><br>
checkbox inputs don't have an ondelect event, nor do they have an onselect event
(well, they might, but it's not appropriate for this purpose). What you want is:
<input name="fotoToevoegen" type="checkbox" value="1"
onclick="EnableInput(this);">
and your function should be:
function EnableInput(chkbox) {
var f = chkbox.form;
f.foto.disabled = !chkbox.checked
var radioButtons = f.positie;
if (typeof radioButtons.length == 'undefined') {
// normalize a single radio button to an array
radioButtons = [ radioButtons ];
}
// handle one or more radio buttons as an array
for (var i = 0; i < radioButtons.length; i++) {
radioButtons[i].disabled = !chkbox.checked;
}
}
Note that you can't simply set the radio button collection disabled=false, you
must determine if there is more then one radio button and then loop through
them, changing each disabled property individually.
Also note that I am using the state of the chkbox (chkbox.checked) to determine
what to set the disabled property to, this means if they uncheck the box later
the various inputs will become disabled again (you may want to reset the checked
property on each of the radio buttons too, to clear any selection they've made,
that's optional).
Of course, now you've created a situation where the inputs are disabled by
default and enabled using JavaScript. If JavaScript is disabled or unavailable,
those inputs will _never_ be available. Better to leave all the inputs enabled
by default, then in <body onload="..."> set them disabled programmatically.
--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ -
http://jibbering.com/faq