Select an option from a datalist and compare index number to another option in a second datalist
If both arrays will have the corresponding values in the same indecies, you can just do this in your onchange events for each drop down:
Side note datalist is not supported in Safari or IE Version <= 9, may want to change to a select element:
<select id="courses" onchange="UpdateFromCourses()">
</select>
//Just make another function like this doing
//the same thing but to the other drop down
function UpdateFromCourses(){
const selIndex = document.getElementById('courses').selectedIndex;
document.getElementById('catalogs').selectedIndex = selIndex;
}
Setting Selected Value for DropDown List in ngFor Anular 5
No need to bind with ngModel
if you are using selected
, code your should be like this
<div class="section">
<h6 style="font-weight:bold">Select a Branch</h6>
<select >
<option *ngFor="let item of this.dataList;let i = index" value="{{item.code}}" [selected]="i == 2">
{{item.name}}
</option>
</select>
</div>
Working Example
Related Topics
Button Not Working on Mobile Devices But Works on Pc Bootstrap
How to Get Checkbox Variables Using Ajax
Laravel Reactjs:Changes Are Not Reflecting After Change in My Js(Reactjs) File
React Component Not Refreshing When Redux State Has Been Updated With Successful Action
How to Execute a JavaScript Function from the Java Part of Jsp
Convert Hex to Binary in JavaScript
What Is the Opposite of Evt.Preventdefault();
Modifying a Query String Without Reloading the Page
How to Return Blank String If Object Is Undefined in Angularjs Forms
How to Customize Header Cell in Pdf Using Jspdf-Autotable Plugin
Use JavaScript to Place Cursor At End of Text in Text Input Element
Passing Multiple Parameters to Function Using Onclick
How to Show Div When a Radio Button Is Clicked in React
Redirecting to Another Page With JavaScript and Jsp
Check If Two Div HTML Elements Intersect
Php Ajax Update MySQL Query Onchange from Dropdown (Filtering)