Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Show form field if radio button checked

Show form field if radio button checked

Show form field if radio button checked

Hello all, I hope you can help me with this.

In my form, I wish to show an additional field (paypal email address) only if the paypal radio button is checked.
I am aware that it would be an onclick event but with all of the class attributes that are on the form and each field, I do not even know where to start.

I tried to google it, but I did not see anything that explained clearly.

The code I have in the input is


<input name="payment_" type="radio" value="paypal" onclick="displayField();" /> 

Below is the html that would need to display if the above radio button is checked.
I just cannot understand what I need to do here.


<fieldset id="email_input" class="control-group" style="margin: 0px; padding: 0px; font-family: 'Open Sans', Arial, Helvetica, sans-serif; border: 0px;">
								<input id="email" class="fullspan default"  maxlength="50" name="paypalemail_" placeholder="Email" style="margin: 10px 0px; padding: 5px 40px 0px 10px; font-family: 'Open Sans', Arial, Helvetica, sans-serif; width: 252px; height: 50px; position: relative; font-size: 14px; color: rgb(82, 82, 82); outline: 0px; background: url('../images/text_field_bg.jpg') no-repeat; left: 0px; top: 0px;" type="text"  /><span class="email-suggestion-container" style="display: block;"></span><span style="display: block; font-size: 11px; margin-left: 5px; color: rgb(142, 142, 142); margin-top: -7px;">What 
								is your Paypal Email?</span></fieldset> 

Any help or guidance would be greatly appreciated

RE: Show form field if radio button checked

set the visibility property of the element using the onClick event of the radio button


Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Show form field if radio button checked

Basically change either the display or visibility property of the element you wish to hide when the radio button is checked. You can even test the radio buttons sate and act accordingly.
In pseudo code:


function displayField()
var checkbox = getCheckbox;
var element getElementtoshow;
element.style.display='block'; / element.style.visiblity='visible';
} else {
element.style.display='none'; / element.style.visiblity='hidden';
} }

Phil AKA Vacunita
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Show form field if radio button checked

I now have it working thanks to your help. One of my issues was the fact that I was putting the <div> in the wrong place, thus cutting off the image and other choice.

Thanks again.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close