Client side script and resetting dropdown lists

A

AB

I am creating a ASP.Net 1.1 (VB) web. I have 2 drop down lists which
are independent of each other. Both are filled from a database on the
pageload. There is also a search button which searches the database
based on the 2 drop down list entries. The first entry in each drop
down list is "Please Select". What I am trying to do via client side
script is to reset the unselected drop down list when the other drop
down list selects a new option. All controls are ASP controls.
The reason for not posting back to the server and to reset the drop
down lists is due to the time it takes and then the end user has to do
it all again on the search option. I would prefer not to use Ajax for
this too. I would prefer javascript due to cross platform ease. I am a
newbie when it comes to java - so be gentle!!
Thanks
 
D

David Mark

I am creating a ASP.Net 1.1 (VB) web. I have 2 drop down lists which
are independent of each other. Both are filled from a database on the
pageload. There is also a search button which searches the database
based on the 2 drop down list entries. The first entry in each drop
down list is "Please Select". What I am trying to do via client side
script is to reset the unselected drop down list when the other drop

Which is the "unselected drop down?" And how are they independent if
one controls the other? Surely they don't each do this as that would
send the user in circles. I assume one select (what you refer to as a
"drop down list") controls the other. I also assume that by "reset"
you mean re-populate with new options.
down list selects a new option. All controls are ASP controls.
The reason for not posting back to the server and to reset the drop
down lists is due to the time it takes and then the end user has to do
it all again on the search option. I would prefer not to use Ajax for

If I (partially) understand the problem, you don't need Ajax for this.
this too. I would prefer javascript due to cross platform ease. I am a
newbie when it comes to java - so be gentle!!

Despite the name, JavaScript has nothing to do with Java.

Post a link to the .NET application (or the generated form) and
describe the desired client-side enhancement in more detail.
 
R

RobG

I am creating a ASP.Net 1.1 (VB) web. I have 2 drop down lists which
are independent of each other. Both are filled from a database on the
pageload.

By "on page load" I presume your server is generating the HTML and
sending it all as one page, the browser has no idea whether it is
dynamically generated or static.

There is also a search button which searches the database
based on the 2 drop down list entries. The first entry in each drop
down list is "Please Select". What I am trying to do via client side
script is to reset the unselected drop down list when the other drop
down list selects a new option.

You want users to select from only one of the drop-downs.
All controls are ASP controls.

Irrelevant here, we only care about what is happening on the client.
The reason for not posting back to the server and to reset the drop
down lists is due to the time it takes and then the end user has to do
it all again on the search option. I would prefer not to use Ajax for
this too. I would prefer javascript due to cross platform ease. I am a
newbie when it comes to java - so be gentle!!

Consider using a single select element with two optgroup elements.
Then you don't need scripting (to implement this functionality) and
your users are less likely to be confused.

Get the page to work as a normal form, then implement some kind of
scripted submit (say using AJAX or whatever) that can be substituted
if suitable script support is detected. Otherwise, the form just
submits.
 
J

Jim

<script type="text/javascript">
function resetSelect(formname,elementname){
var felements=document.forms[formname].elements[elementname];
if(felements.value != null){
felements.value = felements.options[0].value;
}
}
</script>
</head>
<body >
<form name="myform">
Dropdown1 ::
<blockquote>
<select id="sel" name="firstselect"
onChange=resetSelect("myform","secondselect")>
<option name="sports1" value="sports1">--Sports 1--</option>
<option name="football1" value="football1"> FootBall 1</option>
<option name="basketball1" value="basketball1">BasketBall 1</option>
</select>
</blockquote>
<br>

Dropdown2 ::
<blockquote>
<select id="sel" name="secondselect"
onChange=resetSelect("myform","firstselect")>
<option name="sports2" value="sports2">--Sports 2--</option>
<option name="football2" value="football2"> FootBall 2</option>
<option name="basketball2" value="basketball2">BasketBall 2</option>
</select>
</blockquote>
</form>
<hr>
</body>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top