I want the dropdown list option to be displayed based on my value in the text box field. For example, if the value in the text box is 'J' then the dropdown list should display the value for 'J'. It is not populated the dropdown from another dropdown, it is populated a dropdown based on the value in the text box.
This is what i mean when the value in the text box field is J, then it should display the slot based on 'J':
This is the code I've made, but I want to change like it does not need to select an option from the first dropdown.
function dynamicdropdown(listindex)
{
switch (listindex)
{
case "I" :
document.getElementById("reserveSlot").options[0]=new Option("Select Slot","");
document.getElementById("reserveSlot").options[1]=new Option("11:20AM","11:20AM");
break;
case "J" :
document.getElementById("reserveSlot").options[0]=new Option("Select Slot","");
document.getElementById("reserveSlot").options[1]=new Option("1:00PM","1:00PM");
break;
}
return true;
}
<tr>
<td class="category_div" id="category_div" width=25%>STUDENT BLOCK:</td>
<td>
<select id="studBlock" name="studBlock" onchange="javascript:dynamicdropdown(this.options[this.selectedIndex].value);" required>
<option value="">Select Block</option>
<option value="I">I</option>
<option value="J">J</option>
</select>
</td>
</tr>
How do I solve this problem?
