Good day, i have a dropdown that when is selected it must populate the value to the input using data-idbecause i'm already using the idfor something else. 请注意,数据填充到下拉列表select中。
这是input和select
<input type="text" id="@appConfig.Id" data-id="WarehouseInput" data-itemType="int" name="@appConfig.Name" class="form-control" required />
<select type="text" value="SelectWarehouse" name="@appConfig.Name" id="SelectWarehouse" data-itemType="int" class="selectpicker show-tick form-control" data-live-search="true"></select>
When the when the dropdown is selected it need to populate the value oninput
$(function () {
$("#SelectWarehouse").change(function () {
var selectedText = $(this).find("option:selected").text();
var selectedValue = $(this).val();
$(this).attr("data-id", "WarehouseInput");
// var inputid = document.getElementById("WarehouseInput");
//alert("Selected Text: " + selectedText + " Value: " + selectedValue);
});});