Liquid UI - Documentation - 23.11 Search value in an array

23.11 Search value in an array


Prerequisites


Purpose

You can search for a value in an array using the custom find function


User Interface


Validate state button will validate the entered taxable state value


Liquid UI Script

//SAPLSMTR_NAVIGATION.E0100.sjs

// Author: Synactive, Inc. [1065 E. Hillsdale Blvd, Foster City, CA, 94404, USA]
// Email: support@guixt.com; sales@guixt.com;
// Contact: 650.341.3310
// Version: 1.0.0.0

del("X[IMAGE_CONTAINER]");
var stateArray = ["AK","FL","NV","NH","SD","TN","TX","WA","WY"];  // Non taxable states

inputfield ([2,4], "Taxable State", [2,18],{"name":"z_state", "size":2});
pushbutton([4,4], "Validate State",{"size":[1,15], "process":validate_state});

//Returns true or false if the search element is found in the array
Array.prototype.find = function (p){
    for(i=0;i<this.length;i++)    if(this[i] == p) return true;
    return false;
}


function validate_state(){
    if(stateArray.find(z_state)){   
        return('E: Please enter taxable state');
    }
}

Can't find the answers you're looking for?