Note that there are some explanatory texts on larger screens.

plurals
  1. POclearing input fields changing slides and on button input
    primarykey
    data
    text
    <p>I am having multiple slides which will hold multiple forms. I want to clear out the radio input fields when I change the slide or do a submit. Seems to me my approach isnt working. Any suggestion?</p> <p>here is the code I have so far</p> <pre><code>&lt;style&gt; .yesDisplay, .noDisplay, .yesSub{ display:none; } .myc { display:none; } &lt;/style&gt; &lt;script type='text/javascript'&gt; $(function () { var $myc= $('.myc'); var cp = 0; $('#pauseB').click (function () { $myc.hide().eq(cp++).show(); if (cp == $myc.length) cp = 0; }); // check the radio input for Yes function checkYes(){ if($('.yes').attr('checked')){ $('.yesDisplay').show(); }else{ $('.yesDisplay').hide(); } } // check the radio input for No function checkNo(){ if($('.no').attr('checked')){ $('yesDisplay').show(); }else{ $('.noDisplay').hide(); } } $('.cases').change(function(){ checkYes(); checkNo(); }); }); &lt;/script&gt; &lt;div id="pauseB"&gt;Pause&lt;/div&gt; &lt;div id="one" class="myc"&gt;1&lt;br&gt; &lt;form class="cases"&gt; &lt;input type="radio" class="yes" name="first"/&gt;yes &lt;input type="radio" class="no" name="first"/&gt;no &lt;/form&gt; &lt;div class="display"&gt; &lt;div class="yesDisplay"&gt;Secondary Question &lt;form class="cases"&gt; &lt;input type="radio" class="yes1" name="first"/&gt;yes &lt;input type="radio" class="no1" name="first"/&gt;no &lt;/form&gt; &lt;/div&gt; &lt;div class="noDisplay"&gt;&lt;input type="button" value="test"/&gt;&lt;/div&gt; &lt;div class="yesSub"&gt;1.1&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="two" class="myc"&gt;2&lt;br&gt; &lt;form class="cases"&gt; &lt;input type="radio" class="yes" name="first"/&gt;yes &lt;input type="radio" class="no" name="first"/&gt;no &lt;/form&gt; &lt;div class="display"&gt; &lt;div class="yesDisplay"&gt;Secondary Question &lt;form class="cases"&gt; &lt;input type="radio" class="yes1" name="first"/&gt;yes &lt;input type="radio" class="no1" name="first"/&gt;no &lt;/form&gt; &lt;/div&gt; &lt;div class="noDisplay"&gt;no&lt;/div&gt; &lt;div class="yesSub"&gt;1.1&lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div id="three" class="myc"&gt;3&lt;/div&gt; </code></pre>
    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