I have stuck up with an issue of retrieving multiple values from edit text using jquery. I have two dynamic input text box , while retrieving , i can able to get one column of text. How to get both input text box values
<script type="text/javascript">
$(function () {
$("#btnAdd").bind("click", function () {
var div = $("<div />");
div.html(GetDynamicTextBox(""));
$("#TextBoxContainer").append(div);
});
$("#btnGet").bind("click", function () {
var values = "";
var values1 = "";
$("input[name=name]").each(function () {
values += $(this).val() + "\n";
});
alert(values);
});
$("body").on("click", ".remove", function () {
$(this).closest("div").remove();
});
});
function GetDynamicTextBox(value) {
return '<input name = "name" type="text" value = "' + value + '" /> <input name = "designation" type="text" value = "' + value + '" /> ' +
'<input type="button" value="Remove" class="remove" />'
}
</script>
**Output:**name:Ram name:Tom
**Expected Output:**
name:Ram , deisgnation:SE
name:Tom, Designation:PM
You're only getting values of the name inputs, not the designation inputs.
$("input[name=name]").each(function() {
values += "Name:" + $(this).val();
values += ", designation:" + $(this).next().val() + "\n";
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With