File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes radio button textfield Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "radio button textfield" Watch "radio button textfield" New topic

radio button textfield

Steve Sol

Joined: Apr 18, 2009
Posts: 4
Hi, im wanting to have 2 radio buttons in a form
When either one is clicked a textfield should appear.

So when both are clicked, there should be 2 textfields, and when one or the other is clicked, only one textfield.

I need the textfields not to be disabled, but just to not be there, as i need to validate the field if only one radio button has been clicked

Really appreciate the help
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63868

Radio buttons are mutually exclusive, so (assuming that they are in the same group) only one can ever be checked at a time, not two. If they are not in the same group, then radio buttons don't make sense at all. Did you mean check boxes?

In any case, you can create the text fields and hide them with CSS. Upon the check box becoming checked, you use an event handler to change the CSS to make it appear.

You'll need to learn how to establish event handlers, how to modify CSS under script control, and how to use the display CSS property to show and hide elements.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: radio button textfield
It's not a secret anymore!