Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Client side script and resetting dropdown lists

Reply
Thread Tools

Client side script and resetting dropdown lists

 
 
AB
Guest
Posts: n/a
 
      07-31-2007
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

 
Reply With Quote
 
 
 
 
David Mark
Guest
Posts: n/a
 
      07-31-2007
On Jul 31, 1:01 am, AB <(E-Mail Removed)> wrote:
> 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.

> Thanks


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

 
Reply With Quote
 
 
 
 
RobG
Guest
Posts: n/a
 
      07-31-2007
On Jul 31, 3:01 pm, AB <(E-Mail Removed)> wrote:
> 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.


--
Rob

 
Reply With Quote
 
Jim
Guest
Posts: n/a
 
      07-31-2007
<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>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Client-side validation is resetting scroll position jasondavidcarr@gmail.com ASP .Net 0 11-24-2006 07:38 PM
Client side script after client side validation with asp.net 2.0 Boss302 ASP .Net 0 11-21-2006 08:43 AM
Process dropdown lists on client side =?Utf-8?B?RWQgQ2hpdQ==?= ASP .Net 1 08-02-2005 12:21 PM
Server-side script with input parameter from Client-side script Magnus Blomberg ASP .Net 3 04-14-2005 12:21 PM
Help Needed!!! client-side script, server-side code Shawn Mehaffie ASP .Net 4 01-22-2004 05:02 AM



Advertisments