update the focus of <select> menu after reloading the page

Posted on 2004-11-24
Last Modified: 2010-04-06
I have a form that auto submits to itself when an onchange event occurs.  What I can't figure out is how do I now get it so that the menu's focus is now on the value that was previously selected?  Here's the code without database stuff.

<form action="test.asp" method="get" name="form1">
   <select name="options" onChange=document.form1.submit()>
      <option value="1">first</option>
      <option value="2">second</option>
      <option value="3">third</option>

So now when someone selects an option, for example option two, then the page reloads itself and the url will now be:  test.asp?options=2

so now i would probably do a request.form("options") to get the value, but what do I need to write in order for the menu dropdrop to have option two displayed instead of the first option?

The only way I can think of is to have two recordsets.  The first one only has the value selected and the other one has the rest of the options.  I'm sure there is a better way.  Any suggestion?
Question by:smik
    LVL 13

    Accepted Solution

    Is your select menu built from a database?
     If so, then check to see if the value you're outputting == request.form("options"); and if so echo " selected" before closing the option tag.

    Sorry if I'm not grasping the problem right.

    Author Comment

    okay, that worked.

    i just need to write <option value="whatever" selected>whatever</option> for the one that i want selected.

    That was a pretty stupid question...


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    When you work with shopping cart / ecommerce relates web sites, you need to pass the certain form post details to the payment gateway process page with required details for the products items you give to order. Also you may need to track the ordered…
    Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now