How can I retain value of pulldown list in form?

M

Mark R

I have one .asp page with a SELECT pulldown list on it and some INPUT
fields. When SUBMIT is clicked the form data is submitted to that same page
and validated. If INPUT fields are empty the asp code will insert a visual
indicator (e.g. *) to convey that the field must be filled in.
However, if the user has made a selection in the pulldown list and has left
an INPUT field empty, when the form reappears after validation, the pulldown
menu looses its selection and returns to its default value.

Would anyone be able to provide a solution to this?
Or do you need to see the code first?

If someone can help I haven't got great asp knowledge so please be as clear
as possible.

Thanks a lot.
 
R

Roland Hall

in message : I have one .asp page with a SELECT pulldown list on it and some INPUT
: fields. When SUBMIT is clicked the form data is submitted to that same
page
: and validated. If INPUT fields are empty the asp code will insert a visual
: indicator (e.g. *) to convey that the field must be filled in.
: However, if the user has made a selection in the pulldown list and has
left
: an INPUT field empty, when the form reappears after validation, the
pulldown
: menu looses its selection and returns to its default value.
:
: Would anyone be able to provide a solution to this?
: Or do you need to see the code first?
:
: If someone can help I haven't got great asp knowledge so please be as
clear
: as possible.

Test the values when the page is loaded and if not empty, then data has been
entered and you can set the values, along with the * for the fields that are
not empty.

or

You can validate client-side scripting before you post so when you do post,
everything will work and you do not waste an expensive trip to the server.

HTH...

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
M

Mark R

Thanks for your efforts Roland.

I think I just found after much searching, the answer that I was looking
for.
By putting <% if country="United States" then %>SELECTED<%end if%>
in the option tag, the selection won't be lost!

I absolutely love it when you get stuck and eventually find the answer.
Usually though I think I find the answer and then I find another problem
down the line, so I hope it works.....

Sorry if my initial question wasn't clear enough.

Mark

<%
....
country = Request.Form("country")
%>
....
<select name="country">
<option value></option>
<option value="United States"
United States</option>
<option value="Afghanistan"
Afghanistan</option>
<option value="Albania"
Albania</option>
....
 
R

Roland Hall

in message : Thanks for your efforts Roland.

You're welcome.

: I think I just found after much searching, the answer that I was looking
: for.
: By putting <% if country="United States" then %>SELECTED<%end if%>
: in the option tag, the selection won't be lost!

That's what I was referring to with my first option. You're grabbing the
posted value and setting it.

: I absolutely love it when you get stuck and eventually find the answer.
: Usually though I think I find the answer and then I find another problem
: down the line, so I hope it works.....
:
: Sorry if my initial question wasn't clear enough.

Glad you got it working. (O:=


--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top