locked
Here how to handle if (index==-1) in java script . check below my code. RRS feed

  • Question

  • User1878568433 posted

    function OnClientItemSelectedCPT(source, eventArgs) {
    debugger;
    //alert(document.getElementById('<%=hdCptCodeID.ClientID%>').value);

    var CPTID = $('.hdCptCodeIDCss').val();
    var OFEEID = $('.hdCptCodeIDCss').val().replace("txtCode", "txtFee");

    //Star Lokendra on 11/06/2013
    var MODID1 = $('.hdCptCodeIDCss').val().replace("txtCode", "txtModifier1");
    var MODID2 = $('.hdCptCodeIDCss').val().replace("txtCode", "txtModifier2");
    var MODID3 = $('.hdCptCodeIDCss').val().replace("txtCode", "txtModifier3");
    var MODID4 = $('.hdCptCodeIDCss').val().replace("txtCode", "txtModifier4");
    //End

    //ADDED BY SUNITA ON 29TH DEC 2015
    var vctype = $('.hdCptCodeIDCss').val().replace("txtCode", "txtvctype");
    var hdfee = $('.hdCptCodeIDCss').val().replace("txtCode", "hdtxtfee");
    var hdNDC = $('.hdCptCodeIDCss').val().replace("txtCode", "txthdndcavail");
    //END

    //ADDED BY SUNITA ON 7TH JULY 2017 FOR FETCHING ALL THE ICD ON SELECTION OF CPT
    var CHKBOX = $('.hdCptCodeIDCss').val().replace("txtCode", "chkClaim");
    var idtxttxtICD = $('.hdCptCodeIDCss').val().replace("txtCode", "txtICD");
    var idhdICD = $('.hdCptCodeIDCss').val().replace("txtCode", "hdICD");
    //END

    //START :Anupama on 17/June/2014
    var UNIT = $('.hdCptCodeIDCss').val().replace("txtCode", "txtUnit");
    //End


    //START:SHANKAR--12/07/2015
    var ISANESTHESIA = $('.hdCptCodeIDCss').val().replace("txtCode", "txtIsAnesthesiaChecked");
    var ANESTHESIABASEUNIT = $('.hdCptCodeIDCss').val().replace("txtCode", "txtIsAnesthesiaBaseUnit");
    //End

    var FeeID = $('.hdCptCodeIDCss').val();

    var arrFeeID = FeeID.split('ctl00_CP_ClaimEntry_dgClaim_ctl');

    //Added SHANKAR:02042016 To Change Color after selecting CPT
    var DosForm = $('.hdCptCodeIDCss').val().replace("txtCode", "txtDOSFrom");
    var DosTo = $('.hdCptCodeIDCss').val().replace("txtCode", "txtDOSTo");

    debugger;
    var arrFeeID1 = arrFeeID[1].split("_");
    var arrFeeID2 = arrFeeID1[0];
    var arrFeeID3 = arrFeeID1[1];
    var intFeeID4 = parseFloat(arrFeeID2)
    var focuscontrolID;
    intFeeID4 = intFeeID4 - 2;
    if (document.getElementById(focuscontrolID) != null) {
    //alert(document.getElementById(focuscontrolID).id);
    }
    var strControl;
    strControl = 'AutoCompleteCPT_' + intFeeID4;
    var index = $find(strControl)._selectIndex;
    var insvalue;
    if (index != -1) {                                                                                     //Here how to handle if (index==-1) same like if (index !=-1)
    if ($find(strControl).get_completionList().childNodes[index] != null) {
    insvalue = $find(strControl).get_completionList().childNodes[index]._value;
    //alert(insvalue);
    $('.hdACss').val(insvalue);
    var arrinsvalue = $('.hdACss').val().split("|");
    //alert(trim(arrinsvalue[0]));
    //alert(trim(arrinsvalue[1]));
    //alert(trim(arrinsvalue[2]));
    document.getElementById(CPTID).value = trim(arrinsvalue[0]);
    $("#" + CPTID).attr('title', arrinsvalue[1]);

    //ADDED BY SUNITA ON 28TH DEC FOR DOUBLE THE CHARGES IF MODIFIER IS 50 AND TYPE IS BILATERAL
    if ((arrinsvalue[3] == 50 || arrinsvalue[4] == 50 || arrinsvalue[5] == 50 || arrinsvalue[6] == 50) && arrinsvalue[10] == "Bilateral") {
    document.getElementById(OFEEID).value = fnCurrency(trim(arrinsvalue[2]) * 2);
    }

    else {
    document.getElementById(OFEEID).value = fnCurrency(trim(arrinsvalue[2]));
    }

    //END
    //document.getElementById(OFEEID).value = fnCurrency(trim(arrinsvalue[2]));

    //Start Lokendra
    document.getElementById(MODID1).value = arrinsvalue[3];
    document.getElementById(MODID2).value = arrinsvalue[4];
    document.getElementById(MODID3).value = arrinsvalue[5];
    document.getElementById(MODID4).value = arrinsvalue[6];

    //End

    //ADDED BY SUNITA ON 29TH DEC 2015

    document.getElementById(vctype).value = arrinsvalue[10];
    document.getElementById(hdfee).value = arrinsvalue[2];
    document.getElementById(hdNDC).value = arrinsvalue[9];

    //END

    //START: Anupama on 17/June/2014
    document.getElementById(UNIT).value = arrinsvalue[7];
    //End

    //if (document.getElementById(MODID) != null) {
    // document.getElementById(MODID).focus();
    //}
    //START:SHANKAR--12/07/2015
    document.getElementById(ISANESTHESIA).value = arrinsvalue[8];
    document.getElementById(ANESTHESIABASEUNIT).value = arrinsvalue[7];
    //End


    //STARTS: ANUPAMA on 16/Dec/2015
    var ASAValue = $("#txtASA").val();
    if (ASAValue.trim() != "" && arrinsvalue[8].toString() == "1") {
    document.getElementById(MODID2).value = 'P' + ASAValue.trim();
    }
    //END

    //Added SHANKAR:02042016 To Change Color after selecting CPT
    document.getElementById(CPTID).className = "medium-input-box-cc CPT bg-light-yellow-cc";
    document.getElementById(DosForm).className = "DosVal datePic date-input-box-cc frmDos bg-light-yellow-cc";
    document.getElementById(DosTo).className = "DosVal datePic date-input-box-cc toDos bg-light-yellow-cc";

    //ADDED BY SUNITA ON 7TH JULY 2017 FOR FETCHING ALL THE ICD ON SELECTION OF CPT
    // debugger;
    if (document.getElementById(CPTID).value != "") {
    //document.getElementById(CHKBOX).checked = true;
    //document.getElementById(idtxttxtICD).value = "";
    //document.getElementById(idhdICD).value = "";

    if (document.getElementById(idtxttxtICD).value == "") {
    var arrobjID = CPTID.split('_');
    var str1;
    str1 = arrobjID[4].toString();
    str1 = str1.substring(3);
    var str = str1 * 1;
    getICDMapp(str);
    }

    //var rst = getICDFromButtonApplyAll()
    //document.getElementById(CHKBOX).checked = false;
    }
    //END
    }
    }

    }

    Help me as soon as possible.

    Tuesday, November 27, 2018 7:56 AM

All replies

  • User503812343 posted

    what happen when you use like

    if (index == -1) {                                                                                     //Here how to handle if (index==-1) same like if (index !=-1)
    if ($find(strControl).get_completionList().childNodes[index] != null) {
    insvalue = $find(strControl).get_completionList().childNodes[index]._value;
    //alert(insvalue);
    $('.hdACss').val(insvalue);
    var arrinsvalue = $('.hdACss').val().split("|");
    //alert(trim(arrinsvalue[0]));
    //alert(trim(arrinsvalue[1]));
    //alert(trim(arrinsvalue[2]));
    document.getElementById(CPTID).value = trim(arrinsvalue[0]);
    $("#" + CPTID).attr('title', arrinsvalue[1]);
    
    //ADDED BY SUNITA ON 28TH DEC FOR DOUBLE THE CHARGES IF MODIFIER IS 50 AND TYPE IS BILATERAL
    if ((arrinsvalue[3] == 50 || arrinsvalue[4] == 50 || arrinsvalue[5] == 50 || arrinsvalue[6] == 50) && arrinsvalue[10] == "Bilateral") {
    document.getElementById(OFEEID).value = fnCurrency(trim(arrinsvalue[2]) * 2);
    }
    
    else {
    document.getElementById(OFEEID).value = fnCurrency(trim(arrinsvalue[2]));
    }
    
    //END
    //document.getElementById(OFEEID).value = fnCurrency(trim(arrinsvalue[2]));
    
    //Start Lokendra 
    document.getElementById(MODID1).value = arrinsvalue[3];
    document.getElementById(MODID2).value = arrinsvalue[4];
    document.getElementById(MODID3).value = arrinsvalue[5];
    document.getElementById(MODID4).value = arrinsvalue[6];
    
    //End
    
    //ADDED BY SUNITA ON 29TH DEC 2015
    
    document.getElementById(vctype).value = arrinsvalue[10];
    document.getElementById(hdfee).value = arrinsvalue[2];
    document.getElementById(hdNDC).value = arrinsvalue[9];
    
    //END
    
    //START: Anupama on 17/June/2014
    document.getElementById(UNIT).value = arrinsvalue[7];
    //End
    
    //if (document.getElementById(MODID) != null) {
    // document.getElementById(MODID).focus();
    //}
    //START:SHANKAR--12/07/2015
    document.getElementById(ISANESTHESIA).value = arrinsvalue[8];
    document.getElementById(ANESTHESIABASEUNIT).value = arrinsvalue[7];
    //End
    
    
    //STARTS: ANUPAMA on 16/Dec/2015 
    var ASAValue = $("#txtASA").val();
    if (ASAValue.trim() != "" && arrinsvalue[8].toString() == "1") {
    document.getElementById(MODID2).value = 'P' + ASAValue.trim();
    }
    //END
    
    //Added SHANKAR:02042016 To Change Color after selecting CPT
    document.getElementById(CPTID).className = "medium-input-box-cc CPT bg-light-yellow-cc";
    document.getElementById(DosForm).className = "DosVal datePic date-input-box-cc frmDos bg-light-yellow-cc";
    document.getElementById(DosTo).className = "DosVal datePic date-input-box-cc toDos bg-light-yellow-cc";
    
    //ADDED BY SUNITA ON 7TH JULY 2017 FOR FETCHING ALL THE ICD ON SELECTION OF CPT
    // debugger;
    if (document.getElementById(CPTID).value != "") {
    //document.getElementById(CHKBOX).checked = true;
    //document.getElementById(idtxttxtICD).value = "";
    //document.getElementById(idhdICD).value = "";
    
    if (document.getElementById(idtxttxtICD).value == "") {
    var arrobjID = CPTID.split('_');
    var str1;
    str1 = arrobjID[4].toString();
    str1 = str1.substring(3);
    var str = str1 * 1;
    getICDMapp(str);
    }
    
    //var rst = getICDFromButtonApplyAll()
    //document.getElementById(CHKBOX).checked = false;
    }
    //END
    }
    }
    
    }

    Tuesday, November 27, 2018 9:35 PM
  • User1120430333 posted

    if (index != -1) { //Here how to handle if (index==-1) same like if (index !=-1)

    It's either index is equal to or greater than positive 0 or index is less than positive 0 .

    If (index < 0)   // then it is a negative number that is less than positive 0, like -1.

    if (index == 0 || Index > 0) then it is a positive number that is greater than -1.

    Correction

    if (index => 0) then it is a positive number that is greater than -1.

    Tuesday, November 27, 2018 9:50 PM
  • User61956409 posted

    Hi sripadasatpathy,

    if (index != -1) {   //Here how to handle if (index==-1) same like if (index !=-1)

    In your code snippet, you use if to specify a block of code to be executed, if condition index != -1 is true. If you want to handle same for index==-1 condition, you can put your code logic in else code block.

    Besides, you can clarify more about the problem, so that we can understand it better.

    With Regards,

    Fei Han

    Wednesday, November 28, 2018 6:28 AM