...

View Full Version : Radio - Show/Hide



MrTIMarshall
12-10-2010, 03: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">
<div>
<label for="email"><strong>Email:</strong></label>
<input type="text" size="50" name="email" id="email" value="" class="required email" />
</div>
</div>


Thanks in advance,
Tim

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

MrTIMarshall
12-11-2010, 03: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.

abduraooft
12-11-2010, 03: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