Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to hide and show a <tr> on form load in jquery?
    primarykey
    data
    text
    <p>Following is my code snippet from smarty template.</p> <pre><code>&lt;input type="radio" name="newsletter_call_to_action_status" value="1" checked='checked' onclick="select_option(this.value);" {if $data.newsletter_call_to_action_status=='1' } checked {/if}&gt;Yes &lt;input type="radio" name="newsletter_call_to_action_status" value="0" onclick="select_option(this.value);" {if $data.newsletter_call_to_action_status=='0' } checked {/if}&gt;No &lt;tr id="action_link_no" {if $data.newsletter_call_to_action_status=='1' }style="display:;" {else}style="display:none;" {/if}&gt; &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="action_link_yes" height="30"&gt; &lt;td align="right" width="300"&gt; &lt;label&gt;&lt;b&gt;{'Enter call to action text'|signal_on_error:$error_msg:'newsletter_call_to_action_text'}&lt;/b&gt; &lt;strong style="color:red"&gt;*&lt;/strong&gt; &lt;/label&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp; &lt;input type="text" name="newsletter_call_to_action_text" id="newsletter_call_to_action_text" value="{$data.newsletter_call_to_action_text}" maxlength="50" class="inputfield"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt;&amp;nbsp;&lt;/td&gt; &lt;/tr&gt; &lt;tr class="action_link_yes" height="30"&gt; &lt;td align="right" width="300"&gt; &lt;label&gt;&lt;b&gt;{'Enter call to action link'|signal_on_error:$error_msg:' newsletter_call_to_action_link'}&lt;/b&gt; &lt;strong style="color:red"&gt;*&lt;/strong&gt; &lt;/label&gt; &lt;/td&gt; &lt;td&gt;&amp;nbsp; &lt;input type="text" name="newsletter_call_to_action_link" id="newsletter_call_to_action_link" value="{$data.newsletter_call_to_action_link}" class="inputfield"&gt; &lt;/td&gt; &lt;/tr&gt; </code></pre> <p>Now, on form load, if <code>newsletter_call_to_action_status == 1</code> then it should show the <code>tr</code> with <code>class=action_link_yes</code>, and hide the <code>tr</code> using <code>class=action_link_no</code> when the value is <code>0</code>.</p> <p>How can I achieve this?</p>
    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.
 

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