Skip to content
Advertisement

How to save and close a bootstrap modal?

This question have many answers out there but none of those answers solved my problem. I have a modal with some <select> tags. I am trying to save the values from the select options. after they click Save the modal should close but not submit the result yet because the user still need to review stuff after they click save on the modal.

HTML

JavaScript

JS

JavaScript

Since my code is really long, I just copied a modal from google but I added my Save button, so this is the real Save button that my modal is using.

Thanks

EDIT

I changed the id number to letters so now the code doesn’t include any id starting with number, thanks.

PS still need help =/

EDIT

I also tried this one and it did not work

JavaScript

Advertisement

Answer

I’m not sure the id=1 is fine, but you can use this code to simulate a click on the close button (or you can add an id or a class to it).

You may have to remove the onclick="save()"

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement