I have a set of three options that a user can pick. On the third option, when it is selected, I want an input field to be enabled, and if one of the other two are selected, I want this field to be disabled.
Is this possible? And if so, how?
Printable View
I have a set of three options that a user can pick. On the third option, when it is selected, I want an input field to be enabled, and if one of the other two are selected, I want this field to be disabled.
Is this possible? And if so, how?
well, don't they have a disabled property (form objects)?
<option onClick="document.all.whatever.disabled='true'">
or false whenever necessary, or am i way off?
I've been using the following JavaScript function:
function email_access_Clicked(enabled) {
if (enabled == 1) {
document.network_delete_user.email_access.disabled = false
} else {
document.network_delete_user.email_access.disabled = true
}
}
Where network_delete_user is the form name and email_access_disabled is the form element that needs to be disabled/enabled.
Which is used as follows:
<tr>
<td class="print_cell"><b>E-mail: (Mail folders, PAB)</b></td>
<td class="print_cell" align="center"><input type="radio" name="email_delete" value="1" onClick="javascript:email_access_Clicked(0);"></td>
<td class="print_cell" align="center"><input type="radio" name="email_delete" value="0" onClick="javascript:email_access_Clicked(1);">
<select name="email_access" class="holiday-form-submit">
<option value="0">Select User</option>
</select></td>
</tr>
Note that this doesn't work in Netscape 4.7 and that if you disable a form element its value is not passed when the form is submitted - it is treated like it doesn't exist.
DJ
Works great. Thanks.
Does it give a javascript error, or just not work?Quote:
Originally posted by dj4uk
Note that this doesn't work in Netscape 4.7
As far as I remember it was because Netscape 4.7 doesn't support disabled form elements. Netscape 6+ is fine tho'
DJ
I understand that.
Does it give a javascript error is what I want to know.
I don't want my program to be giving people javascript errors, so I need to know if it produces an error, or if it just doesn't work.
Well, I'll have to download 4.7 and see for myself. Thanks.
May I recommend the use of document.getElementById? It's more up to the standard.
True. But that won't work with Netscape 4.7?
The code he has doesn't either.
And I for one have given up supporting NS4. It's so outdated and so little used (<2% I believe), it simply isn't worth it.
Yes also true - up until last week we were supporting 4.7 but after checking stats for various we have dropped support. I only mentioned it as he seemed to want it to work for 4.7.
What would that look like?Quote:
Originally posted by CornedBee
May I recommend the use of document.getElementById? It's more up to the standard.
Or something else?Code:document.getElementById['field_name'].disabled = ?
() instead of [].
Thanks.