I have a selectbox named groupFeaturesSelectBox I set the selected value here :
Javascript side is :
However it is not triggered !
Change event only triggering when I change the select list value but on page load it is not triggered what is wrong ?
2
<select class="form-control mb-2" id="groupFeaturesSelect" name="groupFeaturesSelect" required> <option value="">--Stok Özelliği Seçiniz--</option> @foreach (GroupFeatureDto groupFeature in ViewBag.GroupFeatures) { if(groupFeature.Id == Model.GroupFeatureId) { <option value="@groupFeature.Id" selected>@groupFeature.FeatureName</option> } else { <option value="@groupFeature.Id">@groupFeature.FeatureName</option> } } </select>
Javascript Code :
$(document).ready(function () { $('#groupFeaturesSelect').change(function (event) { var featureId = $(this).val(); $('input[name="groupFeatureId"]').val(featureId); LoadFeatureValues(featureId); }); }
This page is update page so I want it come selected when page loads According to the selected value the other selectbox will appear
If the code is not working after Ajax page load, try the following jQuery code
$('document').on('change','#groupFeaturesSelect',function(event){ var featuredId = $(this).val(); $('input[name="featureId"]').val(featuredId); LoadfeatureValues(featuredId); });
Click here to cancel reply.
2
Answers
Javascript Code :
This page is update page so I want it come selected when page loads According to the selected value the other selectbox will appear
If the code is not working after Ajax page load, try the following jQuery code