...

View Full Version : Changing Selects



mbriney
08-29-2007, 05: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?

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

<body>
<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>

<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>
</select>

</form>
</body>
</html>

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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum