- Here have two list field menu. First
brand
seconditem
- I want if we
select
brand
IBM
thatitem
will selectIBM
too - In other hand, if we
select
brand
HP
thatitem
will selectHP
too
How to do that in javascript.
<select name="brand">
<option>Please Select</option>
<option>IBM</option>
<option>HP</option>
</select>
<select name="item">
<option>Please Select</option>
<option>IBM</option>
<option>HP</option>
</select>
You can add an onchange attribute to your brand select element. When a brand is selected, then the selectItem function will be called, which in turn can select the item that matches the value in the item select element. Also, I recommend that you give IDs to your select elements so that you can use document.getElementById("brand").
Here is the DOM reference for the select element: http://www.w3schools.com/jsref/dom_obj_select.asp
I noticed your options line up with one another, so you could simply reflect the selectedIndex in in the second from the first: