User-271186128 posted
Hi mz1378,
According to your description, I'm not very sure about your question. If you want to get the selected value from the select list, you could reference to the following code.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#testSelect").append($("<option>").attr("value", "1").attr("selected", "selected").text("---Select Field Name---"));
$("#btnAdd").click(function () {
//Add new option.
$("#testSelect").append($("<option>").text($("#txtNew").val()));
});
$("#testSelect").change(function () {
//Show selected value.
alert("Text:" + $("#testSelect option:selected").text() + " Value:" + $("#testSelect option:selected").val());
});
});
</script>
<input id="txtNew" type="text" />
<input id="btnAdd" type="button" value="AddValue" /><br />
<select id="testSelect">
</select>
>>how to prevent the change event from firing when programmaticaly populating the select list?
For this issue, the onchange event will be trigger when the selected value change. So, when we populate the select list, the onchange event not fire.
If you have any other question about my reply, please let me know freely.
Best Regards,
Dillion