Click to See Complete Forum and Search --> : Disabled forms


khayman2001
01-15-2003, 03:12 PM
I'm trying to create a page where you create a character for a game I'm doing. For hair color, I have a select tag opened, and an array set to the different hair colors in the head, and what I want it to do is set the disabled feature for the Other box to false when Other is selected in the pulldown menu, and back to true when any other option is selected, and I can't for the life of me figure it out. I've attached the file in txt file, so I don't have to paste it all here. Any help would be much appreciated.

:confused: Dan

khalidali63
01-15-2003, 05:28 PM
It does not look like that you will be able to that(my humble opinion)

because once you disable the text field
:Hair_color_other"
then it does not trigger any events there fore you can not bring it back to life on mere clicking on it.
You may want put a check box or a set of radio button which will control the ability or disability of these to items.

Khalid

khayman2001
01-15-2003, 05:39 PM
Well, I wanted the trigger to be in the pulldown menu, not the disabled field. When the Other option is selected in the menu, I wanted the text field after it to become abled.

aspro
01-15-2003, 06:37 PM
well what if there are multiple options?
Say there are 5 options and the last one is other??

aspro.

aspro
01-15-2003, 06:43 PM
alright well I am really bad with javascript so if you are able can tou take be throught the code so i can apply it to my form?
thanks,

aspro

aspro
01-15-2003, 07:52 PM
well then how do you know when "other" has been selected in the menu for you to disable it??:confused:

khayman2001
01-15-2003, 08:17 PM
Actually, the true and false were switched, but I got it to work nicely. Thanks a bunch. I was sitting and puzzling over this all day. :D

Dan

khayman2001
01-15-2003, 08:39 PM
You see, the last item, whatever it is, can be accessed by (document.form_name.select_name.selectedIndex == (document.form_name.select_name.options.length - 1)) just like the first option can be accessed by (document.form_name.select_name.selectedIndex == 0) and the second by == 1. What the current code does is takes the length of the list, and subtracts 1, making it equal to the last entry, and then sets the true/false value based on that.

Hope this helps.