Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is a way:</p> <pre><code>&lt;script type="text/javascript"&gt; /* Loops through all input elements finding all checkboxs. Testing if the current checkbox obj is equal to the selected checkbox object. If equal: Set the radio button to the current state of the checkbox. Not equal: Set its children radio buttons checked property false --------------------------------------------------------------------------- */ function setCheckboxs(checkBox) { var parent, i; var checkBoxs = document.getElementsByTagName("input"); for (i = 0; i &lt; checkBoxs.length; i++) { if (checkBoxs[i].getAttribute("type") === "checkbox") { parent = checkBoxs[i].parentNode.parentNode; if (checkBox === checkBoxs[i]) { toggleRadios(parent.childNodes, checkBoxs[i].checked); } else { checkBoxs[i].checked = false; toggleRadios(parent.childNodes, false); } } } } /* Loops through all its children nodes finding a node's attribute equal to radio ----------------------------------------------------------------------------------- */ function toggleRadios(radios, isChecked) { var i; for (i = 0; i &lt; radios.length; i++) { if (radios[i].childNodes.length &gt; 0) { toggleRadios(radios[i].childNodes, isChecked); } if (radios[i].nodeName === "INPUT") { if (radios[i].getAttribute("type") === "radio") { radios[i].checked = isChecked; } } } } &lt;/script&gt; &lt;table border="1"&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt; Select entire row &lt;/th&gt; &lt;th&gt; item_code &lt;/th&gt; &lt;th&gt; page &lt;/th&gt; &lt;th&gt; usd_dn &lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;tr id="534" class="15838"&gt; &lt;td&gt; &lt;input type="checkbox" onclick="setCheckboxs(this);" /&gt; &lt;/td&gt; &lt;td&gt; 15838&lt;input type="radio" name="15838|item_code" value="534" /&gt; &lt;/td&gt; &lt;td&gt; 284&lt;input type="radio" name="15838|page" value="534" /&gt; &lt;/td&gt; &lt;td&gt; $73.00&lt;input type="radio" name="15838|usd_dn" value="534" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="535" class="15838"&gt; &lt;td&gt; &lt;input type="checkbox" onclick="setCheckboxs(this);" /&gt; &lt;/td&gt; &lt;td&gt; 15838 &lt;input type="radio" name="15838|item_code" value="535" /&gt; &lt;/td&gt; &lt;td&gt; 299 &lt;input type="radio" name="15838|page" value="535" /&gt; &lt;/td&gt; &lt;td&gt; $73.00&lt;input type="radio" name="15838|usd_dn" value="535" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="565"&gt; &lt;td&gt; &lt;input type="checkbox" onclick="setCheckboxs(this);" /&gt; &lt;/td&gt; &lt;td&gt; 1611 &lt;input type="radio" name="1611|item_code" value="565" /&gt; &lt;/td&gt; &lt;td&gt; 66&lt;input type="radio" name="1611|page" value="565" /&gt; &lt;/td&gt; &lt;td&gt; $3,350.00 &lt;input type="radio" name="1611|usd_dn" value="565" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="566"&gt; &lt;td&gt; &lt;input type="checkbox" onclick="setCheckboxs(this);" /&gt; &lt;/td&gt; &lt;td&gt; 1611 &lt;input type="radio" name="1611|item_code" value="566" /&gt; &lt;/td&gt; &lt;td&gt; 66&lt;input type="radio" name="1611|page" value="566" /&gt; &lt;/td&gt; &lt;td&gt; $3,225.00 &lt;input type="radio" name="1611|usd_dn" value="566" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre>
    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.
    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