Hi @Roger Porter ,
<form id="CustomerDetails" asp-controller="CustomerDetails" asp-action="UpdateCustomer" method="post" class="mt-3"> <select id="drpUserList" asp-items="@(new SelectList(Model.users, "Id", "FullName"))" class="selectpicker col-offset-1"></select> <a class="btn btn-primary" asp-controller="CustomerDetails" asp-action="AddUserToList" asp-route-???><span class="fas fa-user-plus"></span></a>I basically want to call the AddUserToList action passing the UserID from the selectlist. I can't add the form tag because it is already in one.
I tried to add the form tag just covering the first tab which worked but then my tab select stopped work.
Been searching all day for a solution just don't seem to be able to either find or understand.
Based on your code and description, you want to use the anchor tag to navigate to another view and transfer parameters. If that is the case, you could refer the following sample:
use JQuery to get the selected user id, then change the anchor tag href attribute.
<div class="row">
<div class="col-md-4">
<form id="CustomerDetails" asp-controller="CustomerDetails" asp-action="UpdateCustomer" method="post" class="mt-3">
<select id="drpUserList" asp-items="@(new SelectList(Model.users, "Id", "FullName"))" class="selectpicker col-offset-1"></select>
<a class="btn btn-primary" id="hyperlink" asp-controller="CustomerDetails" asp-action="AddUserToList"><span class="fas fa-user-plus"></span></a>
</form>
</div>
</div>
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
<script type="text/javascript">
$(function () {
$("#drpUserList").change(function () {
//add the parameter
var newurl = $("#hyperlink").attr("href") + "/?userid=" + $(this).val();
//change the hyperlink href attribute.
$("#hyperlink").attr("href", newurl);
});
});
</script>
}
The result as below:
If the answer is helpful, please click "Accept Answer" and upvote it.
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,
Dillion