<script> function in_array(stringToSearch, arrayToSearch) { for (s = 0; s < arrayToSearch.length; s++) { thisEntry = arrayToSearch[s].toString(); if (thisEntry == stringToSearch) { return true; } } return false; } var arr = [1,2,3,4,5]; if(in_array(3,arr)){ alert(1); }else{ alert(2); } </script>