|
-
Oct 15th, 2003, 02:08 PM
#1
Thread Starter
Stuck in the 80s
[Resolved] HTML/Javascript: Disable Form Fields?
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?
Last edited by The Hobo; Oct 17th, 2003 at 11:51 PM.
-
Oct 15th, 2003, 09:16 PM
#2
Lively Member
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?

-morrowasted
-
Oct 16th, 2003, 03:33 AM
#3
Frenzied Member
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
-
Oct 16th, 2003, 12:11 PM
#4
Thread Starter
Stuck in the 80s
Works great. Thanks.
Originally posted by dj4uk
Note that this doesn't work in Netscape 4.7
Does it give a javascript error, or just not work?
-
Oct 16th, 2003, 03:22 PM
#5
Frenzied Member
As far as I remember it was because Netscape 4.7 doesn't support disabled form elements. Netscape 6+ is fine tho'
DJ
-
Oct 16th, 2003, 06:10 PM
#6
Thread Starter
Stuck in the 80s
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.
-
Oct 17th, 2003, 11:51 PM
#7
Thread Starter
Stuck in the 80s
Well, I'll have to download 4.7 and see for myself. Thanks.
-
Oct 21st, 2003, 05:12 AM
#8
May I recommend the use of document.getElementById? It's more up to the standard.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 21st, 2003, 05:16 AM
#9
Frenzied Member
True. But that won't work with Netscape 4.7?
-
Oct 21st, 2003, 05:30 AM
#10
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.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 21st, 2003, 05:34 AM
#11
Frenzied Member
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.
-
Oct 21st, 2003, 10:57 PM
#12
Thread Starter
Stuck in the 80s
Originally posted by CornedBee
May I recommend the use of document.getElementById? It's more up to the standard.
What would that look like?
Code:
document.getElementById['field_name'].disabled = ?
Or something else?
-
Oct 22nd, 2003, 01:01 AM
#13
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Oct 22nd, 2003, 09:14 AM
#14
Thread Starter
Stuck in the 80s
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|