Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat's wrong with my Jquery code .. my loop isn't working
    primarykey
    data
    text
    <p>So I have tried to correct Jquery code below .. In the ESNList text field , multiple values need to be entered separated with a comma , yet they have to be in the same range .. For example , in the condition below in the loop , if you input a number in ESNList between 986329 and 999999 , the second input in the ESNList field should be in the same range as the first input and so on otherwise I throw an alert saying that Both ESNs should be in the same range .. I did a loop to perform the check but it's not working .. Can someone demonstrate to me where the error is .. a fiddle would help tons , I have a hard time sometimes understanding what people try to say on here without good demonstration of where I went wrong .. Below is my code ..</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;script type="text/javascript" src="jquery/jquery-1.8.3.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function () { $(":text").css("border", "2px solid red"); $(":text").keyup(function(){ var enteredData = $(this).val() console.log(enteredData); if (enteredData == "") { $(this).css("border", "2px solid red"); } else { $(this).css("border", "inherit"); } if ($(this).attr("id") == "ESNList"){ esnList = enteredData.split(','); } for(var i = 0; i &lt; esnList.length; i++) { if ( parseInt(esnList[i]) &gt;= 986329 &amp;&amp; parseInt(esnList[i]) &lt;= 999999) { $("#ddl_StxName").val("stx2"); $("#ddl_rtumodel").val("globalstar"); } else if ( parseInt(esnList[i]) &gt;= 660000 &amp;&amp; parseInt(esnList[i]) &lt;= 699999) { $("#ddl_StxName").val("mmt"); $("#ddl_rtumodel").val("globalstar"); } else if ( parseInt(esnList[i]) &gt;= 200000 &amp;&amp; parseInt(esnList[i]) &lt;= 299999) { $("#ddl_StxName").val("stm3"); $("#ddl_rtumodel").val("stmcomtech"); } else if ( parseInt(esnList[i]) &gt;= 1202114 &amp;&amp; parseInt(esnList[i]) &lt;= 1299999) { $("#ddl_StxName").val("smartone"); $("#ddl_rtumodel").val("globalstar"); } else { alert("ESNs should be within the same range"); } } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;form id="provision"&gt; ESNList: &lt;input type="text" id="ESNList" name="ESNList" size="30" /&gt; &lt;br /&gt; ESN Start:&lt;input type="text" id="ESNStart" name="ESNStart" size="10" /&gt; &lt;br /&gt; ESN End: &lt;input type="text" id="ESNStart" name="ESNStart" size="10" /&gt; &lt;br /&gt; UnitName:&lt;input type="text" id="STxName" name="STxName" size="30" /&gt; &lt;br /&gt; Unit Model: &lt;select name="STxName" id="ddl_StxName"&gt; &lt;option value="stx2"&gt;STX2&lt;/option&gt; &lt;option value="stm3" selected&gt;STM3&lt;/option&gt; &lt;option value="acutec"&gt;Acutec&lt;/option&gt; &lt;option value="trackpack"&gt;Trackpack&lt;/option&gt; &lt;option value="mmt"&gt;MMT&lt;/option&gt; &lt;option value="smartone"&gt;Smartone&lt;/option&gt; &lt;option value="smartoneb" &gt;SmartOneB&lt;/option&gt; &lt;/select&gt; &lt;br /&gt; RTU Model Type: &lt;select name="rtumodel" id ="ddl_rtumodel"&gt; &lt;option value="globalstar"&gt;GlobalStar&lt;/option&gt; &lt;option value="both"&gt;Both&lt;/option&gt; &lt;option value="comtech"&gt;Comtech&lt;/option&gt; &lt;option value="stmcomtech"&gt;STMComtech&lt;/option&gt; &lt;/select&gt; &lt;br /&gt; &lt;input type="submit" value ="submit" /&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
    singulars
    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