This question have many answers out there but none of those answers solved my problem. I have a modal with some tags. I am trying to save the value
First, you need to remove onclick="save()"
from your button. You don't need that when you are using the on click function directly $('#save').click(function()...
As was pointed out in the comments by @Eshwaren, you can't use a number to start an id
, so you need fix that as well.
To get the value from a select, you have to be able to identify it. A simple solution would be to give your select element an ID
.
For example:
In your code, you can then assign the value of the select element to a variable.
For example:
var data_1;
$('#save').click(function() {
data_1 = $("#data_1").value();
$('#modalid').modal('hide');
});
You can then use that variable elsewhere in your code.
There are many more possibilities for solving this, but the root of the issue is being able to identify the select elements in code and recording their respective values.