AnsweredAssumed Answered

IF ELSE loop not working

Question asked by cliveswan on Mar 21, 2012
Latest reply on Mar 21, 2012 by DSwingley-esristaff
Hi,

I am trying to select if a record has one or more records.
If it has one record do X, if it has more than one record do Y.


If Underground then return records.
If Not Underground then count the number of records (1, 2 - 10 and +10) and return

IF  I have IF, Else IF, Else IF
Get an empty box.

IF  I have IF, Else IF, Else
It displays a box, but gives the wrong alert. Says there are more than 10 records,
when only 1, 3... records???


Thanks,

Clive

>>>>>>>>>>>>>>>>
function formatIdentifyResults(idResults, theLayerName, contentPane) {
    theResults = {
        displayFieldName : null,
        features : []
    };

    for(var i = 0, il = idResults.length; i < il; i++) {
        var idResult = idResults[i];
        theResults.displayFieldName = idResult.displayFieldName
        theResults.features.push(idResult.feature);
    }



// if(theLayerName == "Underground Stations") {
//         contentPane.setContent(COL_FormatIdentify.LondonUnderground(theResults, theLayerName));
//     } else {
//         contentPane.setContent(layerTabContent(theResults, theLayerName));
//     }
// }

if(theLayerName == "Underground") {
contentPane.setContent(COL_FormatIdentify.Underground(theResults, theLayerName));
} else    if(theLayerName != "Underground")   {

// LOOP TO CATCH >1 RECORD
if( (theLayerName != "Underground") && (idResult <= 1) )
{
alert("1 record");
contentPane.setContent(layerTabContent(theResults, theLayerName)); }

else if ((theLayerName != "Underground") && (idResult > 1) && (idResult <10) )
{
alert("Less than 10 record");
contentPane.setContent(layerTabContent(theResults, theLayerName)); }

else ((theLayerName != "Underground") && (idResult >10) )
{
alert("More than 10 record");
contentPane.setContent(layerTabContent(theResults, theLayerName)); }

   }
}

Outcomes