Page 1 of 1

[SOLVED] Two listboxes - having trouble clearing one when ot

Posted: Mon Sep 13, 2004 5:11 pm
by voltrader
I have two listboxes and would like to clear one when something in the other is selected, and vice versa.

I tried using:

Code: Select all

onChange=&quote;javascript: formname.productsї].selected=false;&quote;
at the end of the SELECT statement, but it doesn't work. I tried onFocus as well.

Any ideas on what's wrong?

Posted: Mon Sep 13, 2004 5:13 pm
by feyd

Code: Select all

formname.elementsї'productsї]'].selectedIndex = 0
maybe...

Posted: Mon Sep 13, 2004 5:18 pm
by voltrader
Hmm, I tried that using both onFocus and onChange to no avail.

Posted: Mon Sep 13, 2004 5:31 pm
by feyd

Code: Select all

<html>
	<head>
	</head>
	<body>
		<form name=&quote;form1&quote;>
			<input type=&quote;text&quote; name=&quote;test&quote; />
			<select name=&quote;products&#1111;]&quote; multiple=&quote;multiple&quote; onchange=&quote;document.forms&#1111;'form1'].elements&#1111;'other&#1111;]'].selectedIndex = -1;&quote;>
				<option value=&quote;10&quote;>10</option>
				<option value=&quote;20&quote;>20</option>
				<option value=&quote;30&quote;>30</option>
				<option value=&quote;40&quote;>40</option>
				<option value=&quote;50&quote;>50</option>
			</select>
			<select name=&quote;other&#1111;]&quote; multiple=&quote;multiple&quote; onchange=&quote;document.forms&#1111;'form1'].elements&#1111;'products&#1111;]'].selectedIndex = -1;&quote;>
				<option value=&quote;60&quote;>60</option>
				<option value=&quote;70&quote;>70</option>
				<option value=&quote;80&quote;>80</option>
				<option value=&quote;90&quote;>90</option>
				<option value=&quote;100&quote;>100</option>
			</select>
		</form>
	</body>
</html>
sure works here...

Posted: Mon Sep 13, 2004 5:36 pm
by voltrader
Feyd -- thanks again... I needed to enclose the form name in the forms-tag, as you showed above: "forms['search'].