Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You would need to keep a hash as you read the data, ignoring data if an 'OPEN' was already found. Then loop through the hash items and output the data:</p> <pre><code>if(res.ROWCOUNT &gt; 0){ var hash = {}; // Hash to store data 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')){ if( hash[SubscriberCode] != undefined &amp;&amp; hash[SubscriberCode].status == 'OPEN' ) { // If we already have OPEN, don't load the data continue; } else { // Else override whatever data you have for this SubscriberCode hash[SubscriberCode] = { status: Status, subscriber: SubscriberCode, service: ServiceCode }; } } } // loop through the hash and output the options for(var x in hash) { lines.push(hash[x].subscriber); $('#selInternet').append( $('&lt;option&gt;&lt;/option&gt;').val(hash[x].subscriber).html(hash[x].subscriber) ); } global_internet_lines = lines; if(lines.length == 0){ $('#divBroadbandUsage').html('No Active Broadband Connections.'); } } </code></pre> <p>I'm not sure what your cases are, but this covers your description I believe. I realize it is silly to have the hash key stored in the data, but for demonstration, this is how you would retrieve other data. This code stores <code>Status</code>, <code>SubscriberCode</code>, and <code>ServiceCode</code>, but your example only uses <code>SubscribercCode</code>. If this is really the case, it is much simpler:</p> <pre><code>if(res.ROWCOUNT &gt; 0){ var hash = {}; // Hash to store data 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')){ // If we see the subscriber code, add it to our hash hash[SubscriberCode] = 1; } } // loop through the hash and output the options for(var sub in hash) { lines.push(sub); $('#selInternet').append( $('&lt;option&gt;&lt;/option&gt;').val(sub).html(sub) ); } global_internet_lines = lines; if(lines.length == 0){ $('#divBroadbandUsage').html('No Active Broadband Connections.'); } } </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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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