0

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 :

enter image description here

modal looks like :

enter image description here

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.

3
  • once the form is submitted, just use the index of that POST array that you have, $_POST['bed_selections'][<number>] Commented Oct 5, 2016 at 5:03
  • I cannot do in that way because it's popup a single modal for each row onclick. so i need to store the previously selected modal data too Commented Oct 5, 2016 at 5:05
  • #Ghost i have extended the explanation little more,please review Commented Oct 5, 2016 at 5:10

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

6 Comments

There is no any specific save button for modal. Only we have one save button which is for all form.
When you open the modal dialog, you can send the row id. Then Update the hidden Input with the same rowid. If you dont have save Button then you can handle modal closing Event. Check jquery documentation for closing event. Or maybe add a save button
"Create a hidden Input for each row." it's for parent table or modal table?
In the table if you have your Form there. How do you Update values in the back End ?
#mightee It's working solution . i have implemented that what you have explained. Thanks dude.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.