Client side script and resetting dropdown lists

Discussion in 'Javascript' started by AB, Jul 31, 2007.

  1. AB

    AB Guest

    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
    AB, Jul 31, 2007
    #1
    1. Advertising

  2. AB

    David Mark Guest

    On Jul 31, 1:01 am, AB <> 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.
    David Mark, Jul 31, 2007
    #2
    1. Advertising

  3. AB

    RobG Guest

    On Jul 31, 3:01 pm, AB <> 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
    RobG, Jul 31, 2007
    #3
  4. AB

    Jim Guest

    <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>
    Jim, Jul 31, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Magnus Blomberg
    Replies:
    3
    Views:
    698
    Magnus Blomberg
    Apr 14, 2005
  2. =?Utf-8?B?RWQgQ2hpdQ==?=

    Process dropdown lists on client side

    =?Utf-8?B?RWQgQ2hpdQ==?=, Aug 2, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    449
    Lars Netzel
    Aug 2, 2005
  3. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    384
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  4. Boss302
    Replies:
    0
    Views:
    1,021
    Boss302
    Nov 21, 2006
  5. Replies:
    0
    Views:
    736
Loading...

Share This Page