I'm trying to get data from inputs of modal and to submit into database. Form has also input fields that aren't inside modal.
I wrote the modal inside <form> but it keep going outside it (I'm watching in inspect element), so I can't get those data.
Is there any chance I make this working?
Pseudo code:
<form> <label>Name</label> <input type="text" name="Name" /> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Check students</button> <!-- Modal --> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">×</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <input type="checkbox" name="students[]" value="student1"> <input type="checkbox" name="students[]" value="student2"> <input type="checkbox" name="students[]" value="student3"> <input type="checkbox" name="students[]" value="student4"> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> <!-- END MODAL --> <button type="submit" class="btn btn-primary" id="main-btn">Create</button> </form>
formelement may be more difficult than putting the form into the modal. Maybe someone else can chime in but I think you may want to trigger the modal and then input the student information. I could be wrong though