473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I retain value of pulldown list in form?

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.
Jul 19 '05 #1
3 4178
"Mark R" wrote in message news:c4*********@titan.btinternet.com...
: 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
Jul 19 '05 #2
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:OP**************@TK2MSFTNGP10.phx.gbl... "Mark R" wrote in message news:c4*********@titan.btinternet.com...
: 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

Jul 19 '05 #3
"Mark R" wrote in message news:c4**********@titan.btinternet.com...
: 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
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: J. Muenchbourg | last post by:
I have an ASP admin script where I'm adding records, and I have a category that already has set name values hard-coded into a selct option pulldown, but if the user wants to create a new category...
9
by: flarkblark | last post by:
I recently had the displeasure of looking at the code required to implement the pop-up menus used in a pulldown menu system for a webpage. The sheer amount of Javascript required was amazing...
1
by: Dom Nicholas | last post by:
Hi, I have a table (inside a form) that is dynamically created ie the user can add / remove rows dynamically. Each table row has 4 columns : a selection pull down list a text field for...
0
by: Jason K | last post by:
As always, hope this is the right group. Very new to .net and all its glorious headaches. Using asp.net 2.0 (trying to at least) and have a problem that is frustrating. I have a FormView setup...
2
by: Simon Wigzell | last post by:
Is it possible within javascript to stop the little pulldown menu (with the values that the browser remembers have previously been entered into the field) from appearing? I have one very dense form...
3
by: Gufus | last post by:
Hi Group... I'm using this /old/ method of pulldown menus, is there another (better) way of doing it? Something that looks better. <script language="JavaScript"> function fetch(){ var...
3
by: ANTISPAM_garycnew_ANTISPAM | last post by:
What is the simplest way to retain the last option value selected in an html select object using javascript? I am currently using a server-side cgi language to accomplish this task, but it adds...
6
by: Ian Davies | last post by:
Hi me again, sorry to be a pain. Ive been struggling with this one all day. Hope you can understand whats happening. First my script is below. Have a look and I'll explain at the bottom what it...
3
by: raaman rai | last post by:
Hi Fellas, i need to understand how to retain the submtted form values during an Edit/Update operation. When i add the information from a form, i retain the form values in the following way incase...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.