displaying or hiding a form text box based on radio/dropdown box selection

adam30k

Gawd
Joined
Aug 18, 2002
Messages
710
Hi folks,
I have a web form and without getting in too much detail, if the default option on a radio or dropbox is selected I'd like the form to submit a pre-defined value and if the user changes the radio or dropbox, then I'd like a text box to be displayed for them to enter their own value in.

Basically, it's a web form for a chat room and if they choose participant they can join without a password, and if they choose moderator they will get a text box to type in the moderator password and get extra control in the chat room. With the open source product I'm using even as participant a password needs to be submitted but I'd like to submit it for them if they aren't the moderator.

I can read and understand HTML pretty comfortably but I can't write something like this from scratch.

Thanks for all the help, I hate to assume that something like this is easy, but I think it's not that difficult to do, no?
 
There are different ways to handle this depending on what you are using; you haven't stated a language/scripting language. The implication at the end is that it is just HTML, but you never stated it was just that.

Makes giving an answer difficult without knowing how you intend to implement it.
 
Sorry I hate being one of those guys. I'd like to use HTML and Javascript but if there's a better way, except for Flash I suppose, I'd be interested.
 
Thanks for all the help, I hate to assume that something like this is easy, but I think it's not that difficult to do, no?

With a javascript API like JQuery its actually quite simple. It would take a bit, typing out a whole guide here but if you just Google and read up a few beginners tutorials you'll see how easy it is.
Jquery beginner guide
Basic show hide
 
jQuery show/hide is perfect for this. If you don't want to use jQuery, you can style a class in CSS with display: none. And then use a Javascript event handler to add that class to the textbox element when you want to hide it. Reverse that to show textbox.
 
Back
Top