• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

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

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?
1 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.
smikAuthor Commented:
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...


Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now