Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is the solution. Thanks @dragon66 to solve my issue. </p> <pre><code>function toggleContent(showHideDiv, switchTextDiv) { var text = document.getElementById(showHideDiv); var ele = document.getElementById(switchTextDiv); var rad_val=''; for (var i=0; i &lt; text.role.length; i++) { if (text.role[i].checked) { rad_val = text.role[i].value; } } if(rad_val=='learner'){ ele.style.display = "block"; } else { ele.style.display = "none"; } } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;table&gt; &lt;tr &gt; &lt;td &gt;&lt;option value="1"&gt; 1 &lt;/option&gt; &lt;/td&gt; &lt;td&gt; Role &lt;/td&gt; &lt;form id="form1"&gt; &lt;td&gt;&lt;label&gt; &lt;input type="radio" name="role" value='learner' onClick="toggleContent('form1','div1')" &gt; Learner &lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;label&gt; &lt;input type="radio" name="role" value='expert' onClick="toggleContent('form1','div1')" &gt; Expert &lt;/label&gt; &lt;/form&gt; &lt;td &gt;&lt;div ID="div1" align=right style="display:none;"&gt; &lt;label class="labell labelUser" &gt;why?&lt;/label&gt; &lt;textarea name="description" align="right" id="description" cols="40" rows="5" class="inputbox"&gt;Why?&lt;/textarea&gt; &lt;span id="descriptionError" class="notifyForUser" spanError&gt;&lt;/span&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr &gt; &lt;td &gt;&lt;option value="2"&gt; 2 &lt;/option&gt; &lt;/td&gt; &lt;td&gt; Role &lt;/td&gt; &lt;form id="form2"&gt; &lt;td&gt;&lt;label&gt; &lt;input type="radio" name="role" value='learner' onClick=toggleContent('form2','div2') &gt; Learner &lt;/label&gt; &lt;/td&gt; &lt;td&gt;&lt;label&gt; &lt;input type="radio" name="role" value='expert' onClick=toggleContent('form2','div2') &gt; Expert &lt;/label&gt; &lt;/td&gt; &lt;/form&gt; &lt;td &gt;&lt;div ID="div2" align=right style="display:none;"&gt; &lt;label class="labell labelUser" &gt;why?&lt;/label&gt; &lt;textarea name="description" align="right" id="description" cols="40" rows="5" class="inputbox"&gt;Why?&lt;/textarea&gt; &lt;span id="descriptionError" class="notifyForUser" spanError&gt;&lt;/span&gt; &lt;/div&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/body&gt; &lt;/html&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.
 

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