Hi @Coreysan ,
Here is a whole working demo about how to get the selected data by using js:
View:
@model TestVM
<form asp-action="Login" asp-controller="Home" method="post">
<select asp-for="@Model.Inventory.CategoryId" class="form-control">
<option value="0">aaa</option>
<option value="1">bbb</option>
</select>
<button type="button" id="PostBtn" class="btn btn-sm btn-primary">Post</button>
</form>
JS in view:
var selectedId= $("#Inventory_CategoryId").val(); //get the selected value
Model design:
public class TestVM
{
public Inventory Inventory { get; set; }
}
public class Inventory
{
public int CategoryId { get; set; }
}
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best Regards,
Rena