Note that there are some explanatory texts on larger screens.

plurals
  1. POjquery function disables all styles on the page
    text
    copied!<p>I've got a form</p> <pre><code>&lt;form action="MakeResponseAction.do" method="POST" id="form-response"&gt; &lt;fieldset&gt; &lt;label for="re"&gt;&lt;fmt:message key="request_id" /&gt;&lt;/label&gt; &lt;select id="re" name="requestid"&gt; &lt;c:forEach items="${requests}" var="requests"&gt; &lt;option value="${requests.id}"&gt;${requests.id}&lt;/option&gt; &lt;/c:forEach&gt; &lt;/select&gt; &lt;label for="aclass"&gt;&lt;fmt:message key="aclass" /&gt;&lt;/label&gt; &lt;input type="text" id="aclass" name="classId" /&gt; &lt;label for="beds"&gt;&lt;fmt:message key="beds_n" /&gt;&lt;/label&gt; &lt;input type="text" id="beds" name="beds" /&gt; &lt;label for="days"&gt;&lt;fmt:message key="days_n" /&gt;&lt;/label&gt; &lt;input type="text" id="days" name="days" /&gt; &lt;label for="fio"&gt;&lt;fmt:message key="fio" /&gt;&lt;/label&gt; &lt;input type="text" id="fio" name="fio" /&gt; &lt;/fieldset&gt; &lt;/form&gt; </code></pre> <p>When user change option in <code>select</code> - I want to set new values in <code>input</code>. I've written a function</p> <pre><code>$("#re").change(function(){ var list = ${requests}; //requests - session attribute var items = $("#re").val(); for(var i = 0; i &lt; list.length; i++) { if (list[i].id == $(this).val()) { $("#aclass").val(list[i].classId); $("#beds").val(list[i].beds); $("#days").val(list[i].days); $("#fio").val(list[i].fio); break; } } }); </code></pre> <p>But when I add it to my page - all styles disappear. I add it like this</p> <pre><code>$(function() { //some other functions $("#re").change(function(){ var list = ${requests}; var items = $("#re").val(); for(var i = 0; i &lt; list.length; i++) { if (list[i].id == $(this).val()) { $("#aclass").val(list[i].classId); $("#beds").val(list[i].beds); $("#days").val(list[i].days); $("#fio").val(list[i].fio); break; } } }); }); </code></pre> <p>What is wrong?</p>
 

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