I have the following :
<script>
$().ready(function() {
$("#myVal#").blur(function() {
var arr = jQuery.makeArray( $("#myArr").val() )
if ( $("#myVal").val().indexOf(arr) == -1 || $("#myVal").val().indexOf(arr) ==0) {
arr.push($("#myVal").val());
}
$("#myArr").val(arr)
});
});
</script>
<form action="" method="post" name="myF" id="myF">
<input type="text" name="myVal" id="myVal" value="">
<input type="text" name="myArr" id="myArr" value="">
<br/>
<input type="submit" name="submit" id="submit" value="go">
</form>
I am trying to check and see if a particular value entered to myVal is already in myArr. If so, don't add to the array. If not, then add to the array. However, the array keeps growing with duplicate values.
what am i doing wrong?
thanks in advance.