i using multiple text box different name . want set values array in collection of list example room name, room desc, bed . these inputs dynamically loaded . have collect details , have set in 1 array list.
my array collection
var roominfo; roominfo.roomname; roominfo.roomdesc; roominfo.roomtypeid; roominfo.bedtype; roominfo.extrabed; roominfo.maxadult; roominfo.maxkids; roominfo.roomstatus; roominfo = []; how values input text box set in these type of array using jquery . please me
my jquery set input val particular value
var roomname = $("input[name='roomname']"); $.each(roomname, function (i, item) { //i=index, item=element in array var i=0; if ($(item).val() == '') { norooms = 1; roomnames = []; $(this).addclass('dttxterror'); e.preventdefault(); } else { norooms = 1; roominfo.roomname.push($(item).val()); // roomnames.roomname.push($(item).val()); console.log(roominfo); } }); in push can not find
roominfo.roomname.push($(item).val());
you should use object save roominfo, this:
var roominfo = { roomname: [] }; so can use push() now
roominfo['roomname'].push($(item).val());
Comments
Post a Comment