subha rr Posted May 23, 2009 Share Posted May 23, 2009 Hi.....To find whether given value is present in an array or not. Enter the value into textbox and find whether the given value is found in array or not....How to write code in javascriptPls help meRegardsSubha Link to comment Share on other sites More sharing options...
Shade Posted May 23, 2009 Share Posted May 23, 2009 var data = new Array(value1, value2, ...... );var value = "myvalue";var num = 0;for(var i = 0; i < data.length; i ++){ if ( data[i] == value ) { num++; }}if ( num > 0 ) { alert("the value " + value + " has occurred " + num + " times"); } else { alert("the value " + value + " was not found"); } Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.