Professional Web Applications Themes

Hidden field with variable problem - ASP

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 ...

  1. #1

    Default 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


    Tom Petersen Guest

  2. #2

    Default Re: Hidden field with variable problem

    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:

    [email]joedomain.com[/email],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" <petertsdsd.sdbor.edu> wrote in message
    news:O5gL2S7eDHA.392TK2MSFTNGP12.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
    >
    >

    Ray at Guest

  3. #3

    Default Re: Hidden field with variable problem

    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) p 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" <petertsdsd.sdbor.edu> wrote in message
    news:O5gL2S7eDHA.392TK2MSFTNGP12.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
    >
    >

    Tom B Guest

  4. Moderated Post

    Default Re: Hidden field with variable problem

    Removed by Administrator
    Tom Petersen Guest
    Moderated Post

  5. Moderated Post

    Default Re: Hidden field with variable problem

    Removed by Administrator
    Ray at Guest
    Moderated Post

  6. #6

    Default Re: Hidden field with variable problem

    Ray,
    That did it, thanks!

    Tom B, thanks for chiming in as well, I went the p route, and learned
    about the Split 'command'


    Tom Petersen Guest

  7. #7

    Default Re: Hidden field with variable problem

    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" <dbrusseeNOSPAMnc.rr.com> wrote in message
    news:jm4cmvcolsvcuno8blbt88sgrn084e0lfo4ax.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:
    > >
    > >joedomain.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.

    Tom Petersen Guest

  8. #8

    Default Re: Hidden field with variable problem

    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:
    >
    >joedomain.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.
    Dan Brussee Guest

  9. #9

    Default Re: Hidden field with variable problem

    Quote from another reply: What you should do then is use the ID number in
    your SELECT
    :P

    Ray at work

    "Dan Brussee" <dbrusseeNOSPAMnc.rr.com> wrote in message
    news:jm4cmvcolsvcuno8blbt88sgrn084e0lfo4ax.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.

    Ray at Guest

Similar Threads

  1. from text field to hidden field
    By Tim Mannah in forum Dreamweaver AppDev
    Replies: 2
    Last Post: September 2nd, 10:42 AM
  2. Replies: 0
    Last Post: January 9th, 03:23 PM
  3. Hidden field?
    By Yatin Bhuta in forum ASP.NET General
    Replies: 3
    Last Post: August 5th, 04:38 AM
  4. How to render a hidden field?
    By Eric Caron in forum ASP.NET General
    Replies: 0
    Last Post: July 2nd, 01:50 PM
  5. hidden field
    By JoŽl in forum ASP.NET General
    Replies: 1
    Last Post: June 30th, 09:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139