Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    390
    Thanks
    48
    Thanked 1 Time in 1 Post

    Radio - Show/Hide

    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;
    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

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Use semicolon instead of comma to separate the statements.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    390
    Thanks
    48
    Thanked 1 Time in 1 Post
    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.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •