function performSearch(){
// sets a temporary clearData array with all the data
clearData = obj_data;
// grabs the object by the id
var valObj = getObjByID("searchFld");
var colObj = getObjByID("searchCol");
// gets the columns and search value
var col = colObj.value;
var value = valObj.value;
// sets the up the searchData array and the counter
var searchData = Array();
var ct = 0;
for(i=0; i<obj_data.length; i++){
// gets the data from a particular column
var searchStr = obj_data[i][col].toString();
// performs an .indexOf on using the value gotten above
if(searchStr.indexOf(value) > -1){
// inserts the data into another array
searchData[searchData.length] = obj_data[i];
// increments the counter
ct++;
}
}
// if the counter is greater than zero, set the count, and the data, do a refersh
if(ct > 0){
obj.setProperty("data/count", ct);
obj.setProperty("data/text", function(i, j){return searchData[i][j]});
obj.refresh();
goToPage(0);
} else {
// if not results were found alert the person
alert("No results were found! Please try again.");
}
}
function clearSearch(){
// sets the original count
obj.setProperty("data/count", 825);
// sets the global clearObject and refreshes the page
obj.setProperty("data/text", function(i, j){return clearData[i][j]});
obj.refresh();
goToPage(0);
}
This topic is archived.