In my View cshtml file I have a code similar to this:
....
<div class="select">
<select name="slct" id="slct">
<option selected disabled>Select 1</option>
<option value=1>Option 1</option>
<option value=2>Option 2</option>
<option value=3>Option 4</option>
....
</select>
</div>
....
<div class="select">
<select name="slct" id="slct">
<option selected disabled>Select N</option>
<option value=100>Option 100</option>
<option value=101>Option 101</option>
<option value=102>Option 102</option>
....
</select>
</div>
....
Basically an N amount of selects, with N possible choices.
What I want to achieve is that when I press a button in the View, after choosing N options, an amount of N tables is inserted into the Database, and I want to do this through a Script, something of this kind at the end of the Code in the cshtml file:
<script src="~/assets/js/jquery.min.js"></script>
<script>
$("something").on('something2', function (e) {
var.........blablablah
});
</script>
How can I make a Script that collects all the Values chosen in the selects, and call this via a button correctly? And what code should I implement in the view's Controller so it receives this data and enters it into the Database using a '_context'?
What happens is that I created a Model containing the variables "Option" and "Date", in my View I generate an interface that allows choosing one of those "Option" for a specific date (each date is a Select), and what I want is that when I press the button, this insert into the database X tables of the Model, with the "Option" that I chose for the corresponding Date.
I hope I have explained it well and I apologize in advance if it wasn't like that. I am new into programming on ASP dot NET and I am having problems understanding how the View Code really communicates with the Controllers, since I am programming my application using Visual Studio 2019, and much of the code is very...automated so to speak, and that confuses me.
The real code of my application is too big and it is private because is for Company that is why I didn't put it, so I felt that presenting my question in this way would be better.
EDIT: Consider that the Model's code is something similar to this.
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace Appp.Models
{
public class OptionDates
{
[Key]
public int Id { get; set; }
[Required]
public string Option { get; set; }
public DateTime Date { get; set; }
}

and what I want is that when I press the button, this insert into the database X tables of the Model, with the "Option" that I chose for the corresponding Date.I am a bit confused with the database requirement.What is your model design?Do you want to select a date together with selecting multiple options?Then pass them to the backend and save them to database?