473,387 Members | 1,486 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

clearing list

Hi

I'm working on a site that has a form on it to do an advanced search on
a database, in the form are 2 list (<select>)

Both these list have items in them, what I want to do is if an items it
selected from list A then it sets list B value to null and of cause the
other way round. The reason is I need to make sure that when the
form is submitted I only pass an item from either list A or B not both
is I do a test on each variable to see what has been selected

I have tried onChange="this.form.town.value=''"

any ideas?

Brian

Jul 23 '05 #1
2 1329
Brian wrote:
Hi

I'm working on a site that has a form on it to do an advanced search on
a database, in the form are 2 list (<select>)

Both these list have items in them, what I want to do is if an items it
selected from list A then it sets list B value to null and of cause the
other way round. The reason is I need to make sure that when the
form is submitted I only pass an item from either list A or B not both
is I do a test on each variable to see what has been selected

I have tried onChange="this.form.town.value=''"

any ideas?


Use an onchange function on each list that sets the other to a default
empty option (or has some value you know to ignore).

<form action="">
<select name="listA" onchange="this.form.listB.selectedIndex=0;">
<option selected></option>
<option value="A1">A1</option>
<option value="A2">A2</option>
</select>
<select name="listB" onchange="this.form.listA.selectedIndex=0;">
<option selected></option>
<option value="B1">B1</option>
<option value="B2">B2</option>
</select>
</form>

--
Rob
Jul 23 '05 #2
Brian wrote:
[...] The reason is I need to make sure that when the form is submitted I
only pass an item from either list A or B not both is I do a test on each
variable to see what has been selected
Note that it does not work without client-side script support:
I have tried onChange="this.form.town.value=''"


If `town' is the name of a select control, this is not supposed to work.
The `value' attribute/property of those objects only specifies the selected
value. Use this instead:

var o = selectElement.options;
if ((o.length = 0) > 0)
{
while (o.length > 0)
{
o[0] = null;
}
}
PointedEars
--
Let us not judge others because of their religion, color or nationality.
We are all just human beings living together on this planet. (poehoe.de)
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Miki Tebeka | last post by:
Hello All, I'd like to bind <CTRL+L> so that it will clear IDLE's screen (in the interactive prompt). Any pointers/suggetions? Thanks. Miki
1
by: hortoristic | last post by:
We are using JavaScript to Enable/Disable certain fields on web pages based on business rules. A simple example is if when using an option type tag, and the two options are Yes and No. If YES...
2
by: Peter Bailey | last post by:
I have a function courtesy of the newsgroup that clears the list box. I would like to now set the listbox back to its initial state where you can see the first item in the list. The same goes for a...
13
by: Michael Kennedy [UB] | last post by:
Hi, I have a situation where I need to clear the event sinks from an event inside a custom class. But I don't know which methods signed up for that event. Consider the following example: ...
65
by: Steven Watanabe | last post by:
I know that the standard idioms for clearing a list are: (1) mylist = (2) del mylist I guess I'm not in the "slicing frame of mind", as someone put it, but can someone explain what the...
1
by: RLN | last post by:
Re: Access 2003 I found a method here in the newsgroup that works for clearing checkboxes, but don't understand a particular line of code and how it works. Here is the code: 1. Dim ctrl As...
10
by: FuzzyLogik | last post by:
<div id="bottomlinks"> <h3>Get Info On</h3> <ul> <li><a href="#">Search Engine Optimization</a></li> <li><a href="#">CSS</a></li> <li><a href="#">HTML / XHTML</a></li> <li><a...
65
by: Leslie Kis-Adam | last post by:
Hi everyone! Does anyone know, if it is possible to clear the screen in ANSI C? If it is,then how? Any help would be appreciated. Laszlo Kis-Adam <dfighter_AT-NOSPAM_freemail.hu
2
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hi, In VS2003 I am able to clear the recent projects and recent files lists by editing the registry (although it seems that there should be a better way). However, when I look in the registry...
1
by: Vayse | last post by:
I have a databound form, frmClients. One of the field is a combo box, comDepartment, which lets a user select a department for the Client. But I can't figure out how to clear the box. That is,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.