Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery / JSON sort results
    primarykey
    data
    text
    <p>I have a ColdFusion method getData() which returns a query object as follows:</p> <pre><code>CustomerCode ServiceCode SubscriberCode Status UserName ------------------------------------------------------------- 811101 8 gertjan OPEN gertjan@blah.net 811101 8 gertjan CLOSING gertjan@blah.net 811101 2 99652444 CLOSED gertjan@blah.net 811101 2 99655000 OPEN gertjan@blah.net </code></pre> <p>Note the first two rows - exactly the same except for Status OPEN and CLOSING respectively.</p> <p>The following function creates a new select option for each row where ServiceCode=8 and Status is either OPEN or CLOSING, which would be the case for both the first two rows.</p> <p>The data ultimately comes via a web service which is out of my control to change. I need to change the jQuery such that if BOTH an OPEN and CLOSING record exists for the same ServiceCode/SubscriberCode combination, which is the case for the first two rows, then only create an option for the OPEN record.</p> <pre><code>function getInternetLines(){ var CustomerCode=global_customerCode; var SessionID=global_sessionID; var lines=[]; $.getJSON("/system.cfc?method=getData&amp;returnformat=json&amp;queryformat=column", {"SessionID":SessionID,"CustomerCode":CustomerCode}, function(res,code) { if(res.ROWCOUNT &gt; 0){ for(var i=0; i&lt;res.ROWCOUNT; i++) { var ServiceCode = res.DATA.ServiceCode[i]; var SubscriberCode = res.DATA.SubscriberCode[i]; var Status = res.DATA.Status[i]; if(ServiceCode == 8 &amp;&amp; (Status == 'OPEN' || Status == 'CLOSING')){ lines.push(SubscriberCode); $('#selInternet').append( $('&lt;option&gt;&lt;/option&gt;').val(SubscriberCode).html(SubscriberCode) ); } } global_internet_lines = lines; if(lines.length == 0){ $('#divBroadbandUsage').html('No Active Broadband Connections.'); } }else{ $('#divBroadbandUsage').html('No Active Broadband Connections.'); } }); } </code></pre> <h2>HTML</h2> <pre><code>&lt;select name="selInternet" id="selInternet" style="width:120px"&gt; &lt;/select&gt; </code></pre> <p>Any assistance greatly appreciated in getting the cleanest approach to this, without multiple loops of the same dataset, for example.</p>
    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