Any body help me
But i am not getting values when clicking button "getValue"
my code is
<html>
<head>
<title>jQuery add / remove textbox example</title>
<script src="jquery.min.js"></script>
<style type="text/css">
div{
padding:8px;
}
</style>
</head>
<body>
<h1>jQuery add / remove textbox example</h1>
<script type="text/javascript">
$(document).ready(function() {
var max_fields = 10; //maximum input boxes allowed
var wrapper = $(".input_fields_wrap"); //Fields wrapper
var add_button = $(".add_field_button"); //Add button ID
var x = 1; //initlal text box count
$(add_button).click(function(e){ //on add input button click
e.preventDefault();
if(x < max_fields){ //max input box allowed
x++; //text box increment
$(wrapper).append('<div><input type="text" name="mytext[]"/><input type="text" name="email[]"/><input type="text" name="mobile[]"/><a href="#" class="remove_field">Remove</a></div>'); //add input box
}
});
$(wrapper).on("click",".remove_field", function(e){ //user click on remove text
e.preventDefault(); $(this).parent('div').remove(); x--;
})
$("#getValue").click(function() {
var arrayLength = mytext.length;
for (var i = 0; i < arrayLength; i++) {
alert(mytext[i]);
//Do something
}
});
});
</script>
</head><body>
<form name="myform" action="save1.php" method="post" enctype="multipart/form-data" >
<div class="input_fields_wrap">
<button class="add_field_button">Add More Fields</button>
<div><input type="text" name="mytext[]" id="mytext">
<input type="text" name="email[]" id="email">
<input type="text" name="mobile[]" id="mobile"></div>
</div>
<input type="button" value="getValue" id="getValue">
<input type="submit" name="submit" />
</form>
</body>
</html>