473,624 Members | 1,993 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4188
"Mark R" wrote in message news:c4******** *@titan.btinter net.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<%en d 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("c ountry")
%>
....
<select name="country">
<option value></option>
<option value="United States"
<% if country="United States" then %>SELECTED<%en d if%>
United States</option> <option value="Afghanis tan"
<% if country="Afghan istan" then %>SELECTED<%en d if%>Afghanistan</option> <option value="Albania"
<% if country="Albani a" then %>SELECTED<%en d if%>Albania</option> ....

"Roland Hall" <nobody@nowhere > wrote in message
news:OP******** ******@TK2MSFTN GP10.phx.gbl... "Mark R" wrote in message news:c4******** *@titan.btinter net.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.btinte rnet.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<%en d 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
2142
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 and not use the select pulldown, the value will end up being " , newvalue" when posting from this sequence of pulldown and input text box: <select name="CategoryName"> <option selected></option> <option value="first">first category</option>...
9
2140
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 and frankly revolting. It is as though the software "engineers" have been thrown out and replaced with "programmers". That is to say, it is a sophomoric hack job, a hideous kludge.
1
7881
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 entering an amount a check box a button
0
1044
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 that uses a second sqldatasource to populate a pulldown list (CatPullDown1) within the Edit Template. That pulldown list is set to AutoPostBack. So far, things seem to be OK. The lits populates correctly, and on autopostback an event fires off...
2
1882
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 where the pulldown menu appears on top of the push button that causes an action when the field content is changed. It is unnescessary and causes an extra click in a very click intensive form. Can it be turned off for the entire page as well? That...
3
2440
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 newtemp; var tempurl;
3
3337
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 a lot of overhead and I would like to move the overhead to the remote client's PC, using javascript. Thank you for your assistance. Respectfully,
6
4628
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 does so far and is failing to do ******************************* <?php session_start(); header("Cache-control: private"); //IE 6 Fix include("myconn.php");
3
3135
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 there is something missing or the values are incorrect. <input type="text" name="camount" tabindex="4" value="<?php echo $form->value("camount"); ?>" > When i edit this information i retrieve the value in the following manner <input...
0
8236
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8475
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4079
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2606
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1785
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.