Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > How can I retain value of pulldown list in form?

Reply
Thread Tools

How can I retain value of pulldown list in form?

 
 
Mark R
Guest
Posts: n/a
 
      04-02-2004
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.


 
Reply With Quote
 
 
 
 
Roland Hall
Guest
Posts: n/a
 
      04-02-2004
"Mark R" wrote in message news:c4j9pb$4k$(E-Mail Removed)...
: 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


 
Reply With Quote
 
 
 
 
Mark R
Guest
Posts: n/a
 
      04-02-2004
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"
<% if country="United States" then %>SELECTED<%end if%>
>United States</option>

<option value="Afghanistan"
<% if country="Afghanistan" then %>SELECTED<%end if%>
>Afghanistan</option>

<option value="Albania"
<% if country="Albania" then %>SELECTED<%end if%>
>Albania</option>

....



"Roland Hall" <nobody@nowhere> wrote in message
news:(E-Mail Removed)...
> "Mark R" wrote in message news:c4j9pb$4k$(E-Mail Removed)...
> : 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
>
>



 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      04-02-2004
"Mark R" wrote in message news:c4jg9e$8in$(E-Mail Removed)...
: 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
FileUpload control not able to retain its value Harinath ASP .Net 1 12-22-2006 12:09 PM
dropdownlist does not retain its selectedindex value on postback. John Blair ASP .Net 2 08-02-2005 10:03 PM
Changing submit function according to what user selects in pulldown list Claire Osborne Javascript 2 02-18-2004 07:32 PM
Page Post Back -- how to retain selecteditem.value of TWO dropdowns??? KathyB ASP .Net 6 06-27-2003 03:33 PM



Advertisments