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

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

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

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

formname.elementsї'productsї]'].selectedIndex = 0
maybe...
Last edited by feyd on Tue Mar 08, 2005 5:14 pm, edited 1 time in total.
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Hmm, I tried that using both onFocus and onChange to no avail.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
Last edited by feyd on Tue Mar 08, 2005 5:15 pm, edited 1 time in total.
User avatar
voltrader
Forum Contributor
Posts: 223
Joined: Wed Jul 07, 2004 12:44 pm
Location: SF Bay Area

Post by voltrader »

Feyd -- thanks again... I needed to enclose the form name in the forms-tag, as you showed above: "forms['search'].
Post Reply