Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I hide the text box in jquery for initial loading?
    text
    copied!<p>I am working in this project where I face this issue. My code works when I click after loading. I have used id for each user. This is the code for active/inactive users. I passed the id to each textbox and span. It is not working. Give some ideas on how to fix this issue. PHP Code:</p> <pre><code> &lt;!--top section start--&gt; &lt;?php $this-&gt;load-&gt;view("header");?&gt; &lt;div id="wrapper" style="height: auto;"&gt; &lt;div class="user_intro"&gt; &lt;table width="600" height="300"&gt; &lt;th style="text-align:left;"&gt;First Name&lt;/th&gt; &lt;th style="text-align:left;"&gt;Email&lt;/th&gt; &lt;th style="text-align:center;"&gt;Active Status &lt;/th&gt; &lt;?php foreach($result as $user) {?&gt; &lt;tr&gt; &lt;td style="text-align:left;"&gt;&lt;a href="&lt;?php echo base_url()?&gt;siteadmin/home/userdetail?userid=&lt;?php echo $user-&gt;user_id; ?&gt;"&gt;&lt;?php echo $user-&gt;first_name;?&gt;&lt;/a&gt;&lt;/td&gt; &lt;td style="text-align:left;"&gt;&lt;a href="&lt;?php echo base_url()?&gt;siteadmin/home/userdetail?userid=&lt;?php echo $user-&gt;user_id; ?&gt;"&gt;&lt;?php echo $user-&gt;email;?&gt;&lt;/a&gt;&lt;/td&gt; &lt;?php if ($user-&gt;status == 1) { ?&gt; &lt;td style="text-align:center;"&gt;&lt;input type="button" id="&lt;?php echo $user-&gt;user_id; ?&gt;" value="" class="on" onclick="togglestyle(this,this.id)" /&gt; &lt;/td&gt; &lt;td&gt;&lt;span id="reason_&lt;?php echo $user-&gt;user_id; ?&gt;"&gt;&lt;input type="text" value="&lt;?php echo $user-&gt;reason; ?&gt;" /&gt; &lt;/span&gt;&lt;/td&gt; &lt;?php } else {?&gt; &lt;td style="text-align:center;"&gt;&lt;input type="button" id="&lt;?php echo $user-&gt;user_id; ?&gt;" value="" class="off" onclick="togglestyle(this,this.id)" /&gt; &lt;/td&gt; &lt;td&gt;&lt;span id="reason_&lt;?php echo $user-&gt;user_id; ?&gt;"&gt;&lt;input type="text" value="&lt;?php echo $user-&gt;reason; ?&gt;" /&gt; &lt;/span&gt;&lt;/td&gt; &lt;?php } ?&gt; &lt;/tr&gt; &lt;?php } ?&gt; &lt;/table&gt; &lt;/div&gt; &lt;/div&gt; &lt;!--fotter section start--&gt; &lt;/div&gt; &lt;?php $this-&gt;load-&gt;view("footer"); ?&gt; </code></pre> <p>javascript code i have added in header file.:</p> <pre><code>&lt;script type="text/javascript"&gt; function togglestyle(el, id) { if (el.className == "on") { $("#reason_" + id).show(); $.ajax({ type: "POST", url: "statuson", data: "userid=" + id, success: function (html) { if (html == 'true') { el.className = "off"; } }, }); } else { $("#reason_" + id).hide(); $.ajax({ type: "POST", url: "statusoff", data: "userid=" + id, success: function (html) { if (html == 'true') { el.className = "on"; } }, }); } } &lt;/script&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