Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to clear the radio buttons using check box un check
    primarykey
    data
    text
    <p>I was trying to clear the radio buttons using check box uncheck. I'm able to get the sample for it. But you have same set is there more than once in my form. I want to have generic method that can be used across the sets. </p> <p>Can some help me. Here is my code. I want to use java script for this.</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script language="JavaScript"&gt; function loopForm(form) { var cbResults = 'Checkboxes: '; var radioResults = 'Radio buttons: '; for (var i = 0; i &lt; form.elements.length; i++ ) { if (form.elements[i].type == 'checkbox') { if (form.elements[i].checked == true) { cbResults += form.elements[i].value + ' '; } } if (form.elements[i].type == 'radio') { if (form.elements[i].checked == true) { radioResults += form.elements[i].value + ' '; } } } document.getElementById("cbResults").innerHTML = cbResults; document.getElementById("radioResults").innerHTML = radioResults; } function loopForm123(form) { for (var i = 0; i &lt; form.elements.length; i++ ) { if (form.elements[i].type == 'checkbox') { if (form.elements[i].checked == true) { alert('insde for loop1'); form.elements[i].checked == false; alert('insde for loop3'); } } if (form.elements[i].type == 'radio') { if (form.elements[i].checked == true) { alert('insde for loop2'); form.elements[i].checked == false; alert('insde for loop4'); } } } } &lt;/script&gt; &lt;body&gt; &lt;form name="thisForm"&gt; I like to program in:&lt;p&gt; &lt;input type="checkbox" value="PHP" &gt;PHP&lt;p&gt; &lt;input type="checkbox" value="Perl"&gt;Perl&lt;p&gt; &lt;input type="checkbox" value="Ruby"&gt;Ruby&lt;p&gt; &lt;input type="checkbox" value="ASP"&gt;ASP&lt;p&gt; &lt;hr&gt; I like to eat:&lt;p&gt; &lt;input type="radio" value="Snickers" name="candy" &gt;Snickers&lt;p&gt; &lt;input type="radio" value="Hershey's" name="candy"&gt;Hershey's&lt;p&gt; &lt;input type="radio" value="M&amp;M's" name="candy"&gt;M&amp;M's&lt;p&gt; &lt;input type="radio" value="Nerds" name="candy"&gt;Nerds&lt;p&gt; &lt;hr&gt; I like to drink:&lt;p&gt; &lt;input type="radio" value="Coke" name="drink" &gt;Coke&lt;p&gt; &lt;input type="radio" value="Gatorade" name="drink"&gt;Gatorade&lt;p&gt; &lt;input type="radio" value="Pepsi" name="drink"&gt;Pepsi&lt;p&gt; &lt;input type="radio" value="Milk" name="drink"&gt;Milk&lt;p&gt; &lt;br&gt; &lt;input type="checkbox" value="Submit" onclick="loopForm123(document.thisForm);"&gt; &lt;/form&gt; &lt;p&gt; &lt;div id="cbResults"&gt;&lt;/div&gt; &lt;div id="radioResults"&gt;&lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>JSFiddle: <a href="http://jsfiddle.net/zzrVN/" rel="nofollow">http://jsfiddle.net/zzrVN/</a></p>
    singulars
    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.
 

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