ASP List/Menu Help.
- Started
- Last post
- 6 Responses
- 187LockDown
I need some help from someone who knows ASP.
I have a form, it posts back to the same page where a block of ASP collects the form vars etc.. and does something with them. I also use some validation so that if you dont enter a correct value you get an error message and the code is not executed further.
My problem: My list menu which allows a user to select a state from a dropdown needs to stay on florida if you get an error, not reset to alabama. How do I make this work. I need to look at the requested form value and say set the option of this menu to the value I recieved.
- jgjh1510
Here is the long way...
==================
to get the form var:
state = request.querystring("state")
====================
To get the dropdown to highlight/select the state they chose(do this for all states):
<option >FL
I have all the states written out like this in an include file. If you like, I can email it to you and save you a lot of typing.
- jgjh1510
Previous post deleted my code example. I will try again?
[option [%if state = "FL" then response.write "selected" end if%]]FL
replace the "["with "<"
- 187LockDown0
Could you send it in an email to me? Sorrry I did not reply quickly, I had to run out last night. I think I understand the second post, but could you send it in an email?
- 187LockDown0
And just to make sure I know what your saying. the"FL" should be replaced with response("state") Because Floida is just one state and I dont want it to always be florida, I want the list box to maintain state.
This would be cake in asp.net considering it defaults to satving any fields state, state as inwhat it was set to last. But in a sense I want it to maintain state for my states. lol
- mike0
there is a much easier way to do this by running a js fnuction when the page loads, if there is an asp value for the state ver, you embed that as the selected argument to the js function call. this will set that option as selected and all you need is a static list of states. make sense?
- 187LockDown0
Makes sense. I will have to figre out the JS function though. I got a JS book - JSDG (Orielly). Ill play around with that idea.