I am trying to set the value of a drop down list from the input box value and also trying to disable it. I am able to disable it but unable to set the value of it from the input box. Can anyone please help here.
Here is my HTML code.
<div class="form-group">
<label>New Image VM Resource Group</label>
<input type="checkbox" id="IsAssociation" name="resourcegroupnull" value="New-Resourcegroup">New Resourcegroup</input>
<select class="form-control" id="groupunderwriter" name="rgnames_option1">
<option value="" disabled selected>Select Image VM Resource Group</option>
<?php
foreach ($rgnames as $item) {
echo "<option value='strtolower($item)'>$item</option>";
}
?>
</select>
Here is my JavaScript code.
$(document).on('change', '#IsAssociation', function () {
if ($(this).prop('checked')) {
$('#groupunderwriter').attr('disabled', 'disabled');
let rgname = prompt("Please enter resource group name");
if (rgname != null) {
$('#groupunderwriter').val('rgname');
}
} else {
$('#groupunderwriter').removeAttr('disabled');
}
});