简体   繁体   中英

how to push two dimensional array values to input field using jquery?

I have an input field which is displayed a modal with row records while onclick event is fired of each row of the parent table.

input field is :

str+=  '<td><input type="text" class="form-control input-sm full-width" data-toggle="modal"  name="bed_selections['+num+']" id="bed_selection'+ num +'" num="'+num+'" onclick="showBedSelection(this)" /></td>';

parent table looks like :

在此处输入图片说明

modal looks like :

在此处输入图片说明

I need to store these data(sno,confirm) to of this input element bed_selections['+num+'] as an array value for back-end processing.

How can i achieve this scenario via js/jquery?

Please tell me your clean solutions.

Create a hidden Input for each row in the table. On modal closing Event get the confirm Check boxes values and put them into an Array. With Array.join(",") you can serialize Array to string and Update your hidden Input with the corresponding rowid. On your Backend get the hidden Input Value, Split the string into Array using the comma (,) delimeter and you have yourself an Array.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM