Code:
function xyz(){
var data = document.frm.search.value;
var arr = new Array("USA","UK","Canada","Italy","France","China");
var flag = 0;
for(var i=0;i<arr.length;i++){
if(data.toLowerCase()==arr[i].toLowerCase()){
flag = 1;
break;
}
}
if(flag==0){
document.write("The given input is not found in the array");
}
else {
document.write("The given input is found in the array");
}
}
</script>
<form name="frm">
<label>Enter data that you search</label>
<input type="text" name="search" />
<br />
<input type="button" value="Search" onClick="xyz()" />
</form>
Comments
Post a Comment