Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Jquery to change div
    text
    copied!<p>UPDATE: So I put all the divs under one table data cell. Now I get the functionality that I want when changing the selection option, but it shows <strong>all</strong> the divs when the page loads up. I just want it to show my pre-selection under <code>{html_options name="program" options=$programs selected=$sanction-&gt;Program}</code></p> <p>The $sanction->Program piece brings in a string of what program is to be preselected. It selects the actual option on the option set initially, but the value is not corresponding. It just shows <strong>every</strong> div.</p> <p>PREVIOUS: I am trying to hide my divs in jquery while showing one div. When I select my one option from six..the div shows up, but you can clearly tell while going through the selections that they are on top of each other. I just want to hide the other divs when I make my one selection and just show that one div. Any help would be appreciated.</p> <p>Here is my code</p> <p>//JQUERY</p> <pre><code> $("select[name=program]").change(function () { $("td#levelCheck div").hide(); $("td#levelCheck div#" + $(this).val()).show(); }); </code></pre> <p>//HTML</p> <pre><code> &lt;table class="form" style="margin-top: 20px;"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;th&gt;Sanction Name&lt;/th&gt; &lt;td&gt;&lt;input type="text" name="name" size="40" maxlength="100" value="{$sanction-&gt;Name}" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;th style="vertical-align: top;"&gt;Select discipline type&lt;/th&gt; &lt;td&gt;{html_options name="program" options=$programs selected=$sanction-&gt;Program}&lt;/td&gt; &lt;/tr&gt; &lt;tr id="trCheck"&gt; &lt;th&gt;&lt;/th&gt; &lt;td id="levelCheck"&gt; &lt;div id="Rhythmic" style="width: 452px;"&gt; {foreach from=$acroLevels item=level} &lt;label&gt; &lt;input type="checkbox" name="{$level-&gt;Code}" value="{$level-&gt;Description}" /&gt; {$level-&gt;Description} &lt;/label&gt; {/foreach} &lt;/div&gt; &lt;div id="Acro" style="width: 452px;"&gt; {foreach from=$acroLevels item=level} &lt;label&gt; &lt;input type="checkbox" name="{$level-&gt;Code}" value="{$level-&gt;Description}" /&gt; {$level-&gt;Description} &lt;/label&gt; {/foreach} &lt;/div&gt; &lt;div id="Men" style="width: 452px;"&gt; {foreach from=$mensLevels item=level} &lt;label&gt; &lt;input type="checkbox" name="{$level-&gt;Code}" value="{$level-&gt;Description}" /&gt; {$level-&gt;Description} &lt;/label&gt; {/foreach} &lt;/div&gt; &lt;div id="TT" style="width: 452px;"&gt; {foreach from=$ttLevels item=level} &lt;label&gt; &lt;input type="checkbox" name="{$level-&gt;Code}" value="{$level-&gt;Description}" /&gt; {$level-&gt;Description} &lt;/label&gt; {/foreach} &lt;/div&gt; &lt;div id="Women" style="width: 452px;"&gt; {foreach from=$womensLevels item=level} &lt;label&gt; &lt;input type="checkbox" name="{$level-&gt;Code}" value="{$level-&gt;Description}" /&gt; {$level-&gt;Description} &lt;/label&gt; {/foreach} &lt;/div&gt; &lt;div id="Group" style="display: none;"&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre>
 

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