View Full Version : Changing Selects

08-29-2007, 06:15 PM
I have two identical selects, they each have the same number of options and the options are in the same order, the only difference is that they each have their own unique ID.

Is it possible to create an OnChange script that if someone selects an option in select #1 it automatically carries that option over to the second select?

08-29-2007, 07:44 PM
<!doctype html public "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title> New Document </title>

<form name="f1" id="f1">

<select name="s1" id="s1" onchange="this.form.s2.selectedIndex = this.selectedIndex;">
<option value="red">red</option>
<option value="orange">orange</option>
<option value="green">green</option>
<option value="blue">blue</option>
<option value="purple">purple</option>

<select name="s2" id="s2">
<option value="apple">apple</option>
<option value="orange">orange</option>
<option value="grapes">grapes</option>
<option value="blueberry">blueberry</option>
<option value="plum">plum</option>


08-29-2007, 07:57 PM
Thank you this is exactly what I was racking my brain to figure out.

08-29-2007, 09:49 PM
Glad to help.