The .map() method is particularly useful for getting or setting the value of a collection of elements.
JQuery.map() can be used when to save as array
var ArrayVal = $('input[name="textbox1[]"]').map(function () { return $(this).val() }).get().join(',');
//the ArrayVal will be comma seperated string
//on retreival part deftn
jQuery.map( arrayOrObject, callback( value, indexOrKey ) )
$.each(ArrayVal, function (key, value) {
alert("key :"+key + " val : " + value);
});
<table>
<tr><td><input type="text" id="txt1" name="textbox1[]" /></td></tr>
<tr><td><input type="text" id="txt2" name="textbox1[]" /></td></tr>
<tr><td><input type="text" id="txt3" name="textbox1[]" /></td></tr>
<tr><td><input type="text" id="txt4" name="textbox1[]" /></td></tr>
</table>
the input type can be either text, checkbox, radio, etc
No comments:
Post a Comment