Trying to read form input

Discussion in 'Classic ASP' started by larkpics, Apr 7, 2003.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi. I am trying to do the following:

    txt_cat = Request("cat" & int_ID)
    txt_nam = Request("name" & int_ID)
    txt_des = Request("desc" & int_ID)

    Where cat, name, and desc plus an integer (int_ID) are text fields in a form. Any suggestions? My form method is post and I have tried using Request.Form(name+value) but nothing seems to work. Thanks.
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    try

    request.form("cat" & int_ID) if you are using post

    quote:Originally posted by larkpics

    Hi. I am trying to do the following:

    txt_cat = Request("cat" & int_ID)
    txt_nam = Request("name" & int_ID)
    txt_des = Request("desc" & int_ID)

    Where cat, name, and desc plus an integer (int_ID) are text fields in a form. Any suggestions? My form method is post and I have tried using Request.Form(name+value) but nothing seems to work. Thanks.
    </blockquote id="quote"></font id="quote">
     
  3. Where are you getting the value of int_ID and are you sure it is the same on the form and on the receiving page?

    try using
    <%
    Dim f

    For Each f In Request.Form
    Response.Write f & " = "
    Response.Write Request.Form(f) & "
    "
    Next
    %>

    to make sure you are getting what you want.



    quote:Originally posted by larkpics

    Hi. I am trying to do the following:

    txt_cat = Request("cat" & int_ID)
    txt_nam = Request("name" & int_ID)
    txt_des = Request("desc" & int_ID)

    Where cat, name, and desc plus an integer (int_ID) are text fields in a form. Any suggestions? My form method is post and I have tried using Request.Form(name+value) but nothing seems to work. Thanks.
    </blockquote id="quote"></font id="quote">

    Jon
    (Information doesn't want to be free, it wants to be sixty-nine cents @ pound)
     
  4. I can't believe I am having this much trouble with this:

    ---------------------THIS------------------
    response.write "serviceID: " & int_ID & "
    "
    'txt_cat = Request.Form("cat" & int_ID)
    'txt_nam = Request.Form("name" & int_ID)
    'txt_des = Request.Form("desc" & int_ID)
    txt_cat = Request.Form("cat0")
    txt_nam = Request.Form("name0")
    txt_des = Request.Form("desc0")
    Response.Write "Category: " & txt_cat & "
    Name: " & txt_nam & "
    Description: " & txt_des & "
    "
    ------------------RETURNS----------------------
    serviceID: 0
    Category:
    Name:
    Description:
    INSERT INTO service (category,name,description) VALUES ('','','');
    -----------------------------------------------
    I have even hard coded it to the text field.
     
  5. Bruce,

    Thanks for getting back to me. I did try

    txt_cat = Request.Form("cat" & int_ID)
    txt_nam = Request.Form("name" & int_ID)
    txt_des = Request.Form("desc" & int_ID)

    but it didn't work. This isn't rocket science but I must have missed something. I can't work on it right now but will try again tonight. Again, thanks for the advice.
     
  6. Bruce

    Bruce DiscountASP.NET Staff

    Post the error pls

    quote:Originally posted by larkpics

    Bruce,

    Thanks for getting back to me. I did try

    txt_cat = Request.Form("cat" & int_ID)
    txt_nam = Request.Form("name" & int_ID)
    txt_des = Request.Form("desc" & int_ID)

    but it didn't work. This isn't rocket science but I must have missed something. I can't work on it right now but will try again tonight. Again, thanks for the advice.
    </blockquote id="quote"></font id="quote">
     
  7. Bruce

    Bruce DiscountASP.NET Staff

    I see that you button is a <a href>

    I don't think you can do that with post method.

    2 suggestions

    a) Try use a submit button

    or

    b) try use request.querystring("cat0")


    quote:Originally posted by larkpics

    Here's the page in question

    larkpics.com/ga/services.asp?e=edit
    </blockquote id="quote"></font id="quote">
     
  8. If your button is an href, you have to submit manually through Javascript. As I recall it goes something like: <A href='mylink.asp' OnClick='Form1.submit();'> where Form1 is the name of the form in a form tag.

    Just in case you are really doing a submit, one old ASP trick I used to use to tell if the IDs for my controls were correct was to change the form tag from 'post' to 'get'. When you do this, the IDs of the controls are shown in the Querystring so you can read them in the browser.

    peter.

    quote:Originally posted by bruce

    I see that you button is a <a href>

    I don't think you can do that with post method.

    2 suggestions

    a) Try use a submit button

    or

    b) try use request.querystring("cat0")


    quote:Originally posted by larkpics

    Here's the page in question

    larkpics.com/ga/services.asp?e=edit
    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">
     
  9. Well I'm not sure if you have fixed this or not but you have to close your request value or I'm certain you will get an error. Then add your int_ID.

    txt_cat = Request("cat") & int_ID

    Hope This Helps,
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page