I have the following code to manage some drop-down menu content that can change based on a textbox (include_Ts) setting.:-
<div class="top">
<strong><font size="2">Include latest T-builds:</font></strong> <input type="checkbox" id="include_Ts"/>
<br><br>
<label><strong><font size="2">Release #1:</font></strong></label>
<select id="selectedBaseRelease">
<script>
$("#selectedBaseRelease").load("/~html/BaseReleaseMenuNoTs.html");
document.querySelector("#include_Ts").addEventListener("change", function(event) {
if (document.getElementById("include_Ts").checked === true) {
$("#selectedBaseRelease").load("/~html/BaseReleaseMenuWithTs.html");
} else {
$("#selectedBaseRelease").load("/~html/BaseReleaseMenuNoTs.html");
}
});
var currentBaseValue = $("#selectedBaseRelease").val();
loadbaseText(currentBaseValue);
</script>
</select>
Here is what the loaded HTML files look like...
<option value="/~releases/K-2015.06/K-2015.06-SP5.AppOps.public">ICC2_K-2015.06-SP5</option>
<option value="/~releases/K-2015.06/K-2015.06-SP4.AppOps.public">ICC2_K-2015.06-SP4</option>
<option value="/~releases/K-2015.06/K-2015.06-SP3.AppOps.public">ICC2_K-2015.06-SP3</option>
<option value="/~releases/K-2015.06/K-2015.06-SP2.AppOps.public">ICC2_K-2015.06-SP2</option>
<option value="/~releases/K-2015.06/K-2015.06-SP1.AppOps.public">ICC2_K-2015.06-SP1</option>
<option value="/~releases/K-2015.06/K-2015.06.AppOps.public" selected >ICC2_K-2015.06</option>
Once the HTML files are loaded, the default selected option is properly displayed in the drop-down, which is great. What is throwing me off, however, is that...
$("#selectedBaseRelease").val()
...is always null. In the above example, I am expecting it to be...
/~releases/K-2015.06/K-2015.06.AppOps.public
Why is JS understanding the selected field in the *.html file, but not the value field?
Thanks!