View Full Version : Radio - Show/Hide

12-10-2010, 02:52 PM
I have been trying to edit some code I have on Accept and Decline. I want to edit it so when you click on [By E-Mail] it shows the div, but when you click on [By Phone] it hides the old div and shoiws a new div to enter a contact number.

My Code;

<input type="radio" id="accept" onclick="document.getElementById('dropdown1').style.display = 'block', document.getElementById('decline').checked = 0"> By E-Mail
<input type="radio" id="decline" onclick="document.getElementById('dropdown1').style.display = 'none',document.getElementById('accept').checked = 0">By Phone<br>
<div id="dropdown1" style="display:none">
<label for="email"><strong>Email:</strong></label>
<input type="text" size="50" name="email" id="email" value="" class="required email" />

Thanks in advance,

12-11-2010, 08:22 AM
Use semicolon instead of comma to separate the statements.

12-11-2010, 02:35 PM
I separated them using a semi-colon, however I don't know how this affects anything as I am not an expert yet... When I tested this, if you click on one radio then the other, they both still work to show and hide but both seem to still be selected.

12-11-2010, 02:42 PM
they both still work to show and hide but both seem to still be selected. Um.. radio buttons are often used as group and for this you need to specify the name attribute with same values to both.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum