I have the following jquery
- $(function () {
- $("#Asset").on("change", function () {
- var categoryId = $(this).val();
- $("#Equipment").empty();
- $("#Equipment").append("<option value=''>--Select Equipment--</option>");
- $.getJSON(`?handler=Equipment&id=${categoryId}`, (data) => {
- $.each(data, function (i, item) {
- $("#Equipment").append(`<option value="${item.value}"> ${item.text}</option>`);
- });
- $('#Equipment').selectpicker({ liveSearch: true });
- });
- $.getJSON(`?handler=AssetDetails&id=${categoryId}`, (data) => {
- if (!jQuery.isEmptyObject(data)) {
- $("#AssetID").val(data.assetID);
- $("#AssetName").val(data.assetName);
- $("#AssetManufacturer").val(data.assetManufacturer);
- }
- });
- });
- });
and a button
- <button class="btn form-control" type="submit" asp-page-handler="Test" asp-route-id="id" id="testid">Button</button>
Select
- <div class="col-md-5">
- <select id="Asset" class="form-control" asp-items="@(new SelectList(string.Empty, "WOAId", "AssetID", "AssetName", "AssetManufacturer"))" data-style="border-warning bg-transparent">
- <option value="">--Select Asset--</option>
- </select>
-
- </div>
How do I pass $("#AssetID").val(data.assetID); as id in button asp-route-id?