473,386 Members | 1,785 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,386 software developers and data experts.

Hidden field with variable problem

Here is the code:
<SELECT NAME="email" style="font-family: Verdana; font-size: 10pt; "
size="1">
<%
DO WHILE NOT objRS.EOF
strEmail = objRS("email")
strLName = objRS("last_name")
strFName = objRS("first_name")
%>
<option value="<% =strEmail %>"><%= strLName & ", " & strFName %>
</option>
<%
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing

%>

</SELECT></font></b></td>
<input type="hidden" name="last_name" value="<% =strLName %>">

snip

<INPUT TYPE=SUBMIT VALUE="Submit Form">
Now when the form is submitted to my results page that updates the database,
the value for strLName is, obvioulsy, the last record in the database. How
do I make the value equal what the user selected from the drop down?

Or in other words, if my drop down value is:
1
2
3
4
5,
and the user picks 3, the value that gets added to the db is always 5...

TIA
Jul 19 '05 #1
8 4246
Easiest way that wouldn't rely on client side coding would be to do:
<option value="<%=strEmail & "," & strLName%>"><%= strLName & ", " &
strFName %></option>
Then on the page that processes this data, the value of
request.form("email") would be something like:

jo*@domain.com,Bergey

So, you can then do

aEmailInfo = Split(REquest.Form("email"), ",")
sEmail = aEmailInfo(0)
sLName = aEmailInfo(1)
Basically, you have to pass the last name in a form field. But let me ask
you this. If the info is coming from the database, why do you need to do
this? Isn't this person's information already in the database? Like, it
seems that if I were in your database, I could tell you my e-mail address,
and you could then in turn tell me my last name, so why do you need to
update this column like this?

Ray at work



"Tom Petersen" <pe****@sdsd.sdbor.edu> wrote in message
news:O5*************@TK2MSFTNGP12.phx.gbl...
Here is the code:
<SELECT NAME="email" style="font-family: Verdana; font-size: 10pt; "
size="1">
<%
DO WHILE NOT objRS.EOF
strEmail = objRS("email")
strLName = objRS("last_name")
strFName = objRS("first_name")
%>
<option value="<% =strEmail %>"><%= strLName & ", " & strFName %>
</option>
<%
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing

%>

</SELECT></font></b></td>
<input type="hidden" name="last_name" value="<% =strLName %>">

snip

<INPUT TYPE=SUBMIT VALUE="Submit Form">
Now when the form is submitted to my results page that updates the database, the value for strLName is, obvioulsy, the last record in the database. How do I make the value equal what the user selected from the drop down?

Or in other words, if my drop down value is:
1
2
3
4
5,
and the user picks 3, the value that gets added to the db is always 5...

TIA

Jul 19 '05 #2
The value of your select is not the strLName it's the strEmail.
Why do you want to use a hidden field?
You shouldn't use strEmail as a unique value, my wife and I share an email
account?

I'll assume that you know what you're doing and the above is my error.
What you'll need to do is either a)re-query the database based on the
selected email or b) parse out the last name from the content of the
<select> on the client, and update your hidden form.
To do "b" would require some client side scripting such as javascript.
"Tom Petersen" <pe****@sdsd.sdbor.edu> wrote in message
news:O5*************@TK2MSFTNGP12.phx.gbl...
Here is the code:
<SELECT NAME="email" style="font-family: Verdana; font-size: 10pt; "
size="1">
<%
DO WHILE NOT objRS.EOF
strEmail = objRS("email")
strLName = objRS("last_name")
strFName = objRS("first_name")
%>
<option value="<% =strEmail %>"><%= strLName & ", " & strFName %>
</option>
<%
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing

%>

</SELECT></font></b></td>
<input type="hidden" name="last_name" value="<% =strLName %>">

snip

<INPUT TYPE=SUBMIT VALUE="Submit Form">
Now when the form is submitted to my results page that updates the database, the value for strLName is, obvioulsy, the last record in the database. How do I make the value equal what the user selected from the drop down?

Or in other words, if my drop down value is:
1
2
3
4
5,
and the user picks 3, the value that gets added to the db is always 5...

TIA

Jul 19 '05 #3
I think I am confusing myself!
I have two databases, one already contains email, last_name and first_name.
My problem is updating the second database with all of the same fields when
my form is only 'collecting' the email. So can I still use your method if I
also need the first name, how does the Split work if I 'need' a second
comma?

Or should I use Tom B's suggestion and grab the info I need from database
base 1 using a query like Select last_name, first_name from xxx Where email
= request.form(email), using the correct syntax of course... Whic do you
think would be better?

Thanks!

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:u1**************@TK2MSFTNGP12.phx.gbl...
Easiest way that wouldn't rely on client side coding would be to do:
<option value="<%=strEmail & "," & strLName%>"><%= strLName & ", " &
strFName %></option>
Then on the page that processes this data, the value of
request.form("email") would be something like:

jo*@domain.com,Bergey

So, you can then do

aEmailInfo = Split(REquest.Form("email"), ",")
sEmail = aEmailInfo(0)
sLName = aEmailInfo(1)
Basically, you have to pass the last name in a form field. But let me ask
you this. If the info is coming from the database, why do you need to do
this? Isn't this person's information already in the database? Like, it
seems that if I were in your database, I could tell you my e-mail address,
and you could then in turn tell me my last name, so why do you need to
update this column like this?

Ray at work



"Tom Petersen" <pe****@sdsd.sdbor.edu> wrote in message
news:O5*************@TK2MSFTNGP12.phx.gbl...
Here is the code:
<SELECT NAME="email" style="font-family: Verdana; font-size: 10pt; "
size="1">
<%
DO WHILE NOT objRS.EOF
strEmail = objRS("email")
strLName = objRS("last_name")
strFName = objRS("first_name")
%>
<option value="<% =strEmail %>"><%= strLName & ", " & strFName %>
</option>
<%
objRS.MoveNext
Loop

objRS.Close
Set objRS = Nothing

%>

</SELECT></font></b></td>
<input type="hidden" name="last_name" value="<% =strLName %>">

snip

<INPUT TYPE=SUBMIT VALUE="Submit Form">
Now when the form is submitted to my results page that updates the

database,
the value for strLName is, obvioulsy, the last record in the database.

How
do I make the value equal what the user selected from the drop down?

Or in other words, if my drop down value is:
1
2
3
4
5,
and the user picks 3, the value that gets added to the db is always 5...

TIA


Jul 19 '05 #4

"Tom Petersen" <pe****@sdsd.sdbor.edu> wrote in message
news:%2***************@TK2MSFTNGP10.phx.gbl...
I think I am confusing myself!
I have two databases,
Eegs!
one already contains email, last_name and first_name.
My problem is updating the second database with all of the same fields when my form is only 'collecting' the email. So can I still use your method if I also need the first name, how does the Split work if I 'need' a second
comma?
You can have as many commas as you like, or you can use any character.
Split() will create an array by splitting the string on whatever
character(s) you specify. For example:

TheString="ra*@mydomain.com|Costanzo|Ray"
TheSplitStringArray = Split(TheString, "|")

You'll then have an array with three elements:
TheSplitStringArray(0) = "ra*@mydomain.com"
TheSplitStringArray(1) = "Costanzo"
TheSplitStringArray(2) = "Ray"



Or should I use Tom B's suggestion and grab the info I need from database
base 1 using a query like Select last_name, first_name from xxx Where email = request.form(email), using the correct syntax of course... Whic do you
think would be better?


I would use Tom's suggestion of NOT using e-mail addresses as your unique
identifier. Let's assume your data in database1 looks like this:

ID Email LName Fname

What you should do then is use the ID number in your SELECT, and when the
person selects the value and submits the form, query the e-mail address,
last name, and firstname from database1 and do what you have to do with it
in database2 then.

Ray at work

Jul 19 '05 #5
Ray,
That did it, thanks!

Tom B, thanks for chiming in as well, I went the parse route, and learned
about the Split 'command'
Jul 19 '05 #6
On Mon, 15 Sep 2003 14:21:28 -0400, "Ray at <%=sLocation%>"
<myfirstname at lane34 dot com> wrote:
Easiest way that wouldn't rely on client side coding would be to do:
<option value="<%=strEmail & "," & strLName%>"><%= strLName & ", " &
strFName %></option>
Then on the page that processes this data, the value of
request.form("email") would be something like:

jo*@domain.com,Bergey

So, you can then do

aEmailInfo = Split(REquest.Form("email"), ",")
sEmail = aEmailInfo(0)
sLName = aEmailInfo(1)
Basically, you have to pass the last name in a form field. But let me ask
you this. If the info is coming from the database, why do you need to do
this? Isn't this person's information already in the database? Like, it
seems that if I were in your database, I could tell you my e-mail address,
and you could then in turn tell me my last name, so why do you need to
update this column like this?

Ray at work

Or, of course (assuming you have a unique ID for your records) just
use the ID as the value and look up what you need using a query on
that ID field.
Jul 19 '05 #7
Quote from another reply: What you should do then is use the ID number in
your SELECT
:P

Ray at work

"Dan Brussee" <db******@NOSPAMnc.rr.com> wrote in message
news:jm********************************@4ax.com...

Or, of course (assuming you have a unique ID for your records) just
use the ID as the value and look up what you need using a query on
that ID field.

Jul 19 '05 #8
Dan, good call, didn't even think of that, but I did get what I needed
working, so I'm not going to touch it! :)
"Dan Brussee" <db******@NOSPAMnc.rr.com> wrote in message
news:jm********************************@4ax.com...
On Mon, 15 Sep 2003 14:21:28 -0400, "Ray at <%=sLocation%>"
<myfirstname at lane34 dot com> wrote:
Easiest way that wouldn't rely on client side coding would be to do:
<option value="<%=strEmail & "," & strLName%>"><%= strLName & ", " &
strFName %></option>
Then on the page that processes this data, the value of
request.form("email") would be something like:

jo*@domain.com,Bergey

So, you can then do

aEmailInfo = Split(REquest.Form("email"), ",")
sEmail = aEmailInfo(0)
sLName = aEmailInfo(1)
Basically, you have to pass the last name in a form field. But let me askyou this. If the info is coming from the database, why do you need to do
this? Isn't this person's information already in the database? Like, it
seems that if I were in your database, I could tell you my e-mail address,and you could then in turn tell me my last name, so why do you need to
update this column like this?

Ray at work

Or, of course (assuming you have a unique ID for your records) just
use the ID as the value and look up what you need using a query on
that ID field.

Jul 19 '05 #9

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

Similar topics

10
by: Randell D. | last post by:
Folks, Perhaps someone can figure this out - this is 'the process of my script' I have a form whereby I can add multiple contacts to a single address. There is only one...
3
by: Yatin Bhuta | last post by:
Hi, I have WebPage1 which has a link to go to WebPage2. This link passes a value to WebPage2. In the page_load event I get this value using Request.QueryString and put it in a public data member...
4
by: Alex | last post by:
Is there any way to delete the value of a html hidden input field from code-behind? I use an html hidden input to store an array of data. I collect this data using Request.Form or Request.Params....
2
by: Rodusa | last post by:
I have a hidden field inside one datagrid which I can't get to make it keep its state after a postback event. Look field: <input type="hidden" id="TxtHiddenItem_id" name="TxtHiddenItem_id"...
4
by: Joe | last post by:
Hello All: I have two webforms (WebForm1.aspx and WebForm2.aspx) that inherit from a base class called BasePage.aspx. BasePage.aspx has no user interface but inherits System.Web.UI.Page...
4
by: WB | last post by:
Hi, I need to validate a hidden input in my webform to ensure that it's got value. The controls look something like this: <input id="HidSelectedStates" type="hidden" runat="server" /><br...
3
by: ThunderMusic | last post by:
Hi, I have a custom control that draws many thing on the screen including a hidden field. This hidden field's value is modified through client code. What I want to do is the following : When there...
5
by: james.calhoun | last post by:
I feel like this should be really easy... I want a hidden field in a form to have its value defined when someone clicks on a link. So if they click on link "A" the value of the hidden field...
7
by: tshad | last post by:
How do you hide an asp.net object and still be able to access it? I had my email in a session variable, but you can't access the session variable from Javascript (I don't think - since Javascript...
5
by: laredotornado | last post by:
Hi, Is there a way to trigger an event when the value of a hidden field changes? At a certain point in time my hidden field is getting changed to a value that I don't want but I can't find a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.