Note that there are some explanatory texts on larger screens.

plurals
  1. POradio button deselcted but form still appearing?
    primarykey
    data
    text
    <p>I've got a form that I want the user to fill out, it contains two radio buttons and when each one is selected, it brings up further options for the user to fill out - however when I click on one radio button, the select another, the previous form information (that is associated with the other button) is still there - I'm not sure how to code it so that when the button is deselected, the form fields also disappear along with it.</p> <p>The code is below, but I also included a <a href="http://jsfiddle.net/FV5KN/" rel="nofollow">jfiddle link</a> so that you can see it in action.</p> <p>form</p> <pre><code>&lt;form action="" method="post" id="contactForm"&gt; &lt;strong&gt;&lt;label for="box1" id="box1_label"&gt;name&lt;/label&gt;&lt;/strong&gt; &lt;br /&gt; &lt;input type="text" name="box1" class="tentry" id="namae" tabindex="1" /&gt; &lt;br /&gt; &lt;div class="error" id="box1_error"&gt; &lt;label for="box1"&gt;this field is required!&lt;/label&gt; &lt;/div&gt; &lt;strong&gt;email&lt;/strong&gt; &lt;br /&gt; &lt;input type="text" class="tentry" name="box2" id="tegami" tabindex="2" /&gt; &lt;br /&gt; &lt;div class="error" id="box2_error"&gt; &lt;label for="box2"&gt;this field is required!&lt;/label&gt; &lt;/div&gt; &lt;strong&gt;lets...&lt;/strong&gt; &lt;br /&gt; &lt;input name="radio1" type="radio" id="client" value="work together" tabindex="3" /&gt; &lt;label for="client"&gt;work together &lt;label&gt;&amp;nbsp; &lt;input name="radio1" type="radio" id="chatter" value="chit-chat" tabindex="4" /&gt; &lt;label for="chatter"&gt;chat&lt;/label&gt; &lt;div class="error" id="radio1_error"&gt; &lt;label for="radio1"&gt;you must select a button!&lt;/label&gt; &lt;/div&gt; &lt;div id="clientBox" style="display: none;"&gt; &lt;strong&gt;&lt;label for="website" id="website_label"&gt;website&lt;/label&gt;&lt;/strong&gt; &lt;br /&gt; &lt;input type="text" class="tentry" name="website" id="web" value="http://" /&gt; &lt;br /&gt; &lt;strong&gt;&lt;label for="info" id="info_label"&gt;tell me about your project!&lt;/label&gt;&lt;/strong&gt; &lt;br /&gt; &lt;textarea name="info" rows="6" cols="35" id="infoArea"&gt;so what do you need?&lt;/textarea&gt; &lt;/div&gt; &lt;div id="chatterBox" style="display: none;"&gt; &lt;strong&gt;&lt;label for="chatter" id="chatter_label"&gt;let's talk!&lt;/label&gt;&lt;/strong&gt; &lt;br /&gt; &lt;textarea name="chatter" rows="6" cols="35" id="infoArea"&gt;what's on your mind?&lt;/textarea&gt; &lt;/div&gt; &lt;br /&gt; &lt;input type="submit" name="submit" class="button" id="submit_btn" value="Send" /&gt; &lt;/form&gt; </code></pre> <p>jQuery</p> <pre><code>//Display extra forms on radio button press $('#client').click(function () { if ($('#client').is(':checked')) { $('#clientBox').show(); } else { $('#clientBox').hide(); } }); $('#chatter').click(function () { if ($('#chatter').is(':checked')) { $('#chatterBox').show(); } }); </code></pre> <p>Thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload