#1
  1. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0

    [Classic ASP] about request.form


    can i specify which request form that i want to process...

    maybe like this :
    if Not IsEmpty(Request.Form("test2")) then
    ...
    end if

    sorry for the bad english

    here's my code :
    Code:
    <%
    	if Not IsEmpty(Request.Form) then
    		response.write(request.form("text1"))
    		response.write("<br> + <br>")
                    response.write(request.form("text2"))
    	end if
    %>
    
    <body>
      <table id="table1">
        <tr>
          <td>
            <form id="test1" action="" method="post">
              <input id="text1" name="text1" type="Text">
              <input id="button1" type="button" value="button" onclick="javascript:document.getElementById('test1').submit();">
            </form>
          </td>
        </tr>
      </table>
      <br>
      <hr>
      <br> 
      <table id="table2">
        <tr>
          <td>
            <form id="test2" action="" method="post">
              <input id="text2" name="text2" type="text">
              <input id="button2" type="button" value="button" onclick="javascript:document.getElementById('test2').submit();">
            </form>
          </td>
        </tr>
      </table>
    </body>
  2. #2
  3. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Mar 2006
    Location
    South Wales
    Posts
    3,674
    Rep Power
    2043
    --> Moved to ASP Forum

    You can check to see if the Request.Form collection contains values and then test the length of each value, eg:
    Code:
    <%
    Dim whichValue
    If Request.Form.Count > 0 Then
        If Len(Trim(Request.Form("text1"))) > 0 Then
               whichValue = Request.Form("text1")
        Else
               whichValue = Request.Form("text2")
        End If
    End If
    %>
    What exactly do you need to do?
  4. #3
  5. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0
    i want to give specific process for each form submitted

    something like this


    if (form1 submitted) then
    do process x
    end if


    if (form2 submitted) then
    do process y
    end if



    the problem is when i use
    if(request.form) <-- i want this to respond to specific form only
  6. #4
  7. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Mar 2006
    Location
    South Wales
    Posts
    3,674
    Rep Power
    2043
    You could use submit buttons to submit teh forms and then test the value of the submit button, eg:
    Code:
    <html>
    <%
    If Request.Form("btnsubmit") = "Submit Form 1" Then
    	'Form 1 submitted
    Else
    	'Form 2 Submitted
    End IF
    %>
    <body>
      <table id="table1">
        <tr>
          <td>
            <form name="test1" id="test1" action="test2.asp" method="post">
              	<input id="text1" name="text1" type="Text">
              	<input type="submit" value="Submit Form 1" name="btnSubmit">
            </form>
          </td>
        </tr>
      </table>
      <br>
      <hr>
      <br>
      <table id="table2">
        <tr>
          <td>
            <form name="test2" id="test2" action="test2.asp" method="post">
              	<input id="text2" name="text2" type="text">
             	<input type="submit" value="Submit Form 2" name="btnSubmit">
            </form>
          </td>
        </tr>
      </table>
    </body>
  8. #5
  9. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0
    aaah~

    your right, thats what i needed,
    however, can i used hyperlink instead of button to do that?


    btw thx sync_or_swim
  10. #6
  11. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Mar 2006
    Location
    South Wales
    Posts
    3,674
    Rep Power
    2043
    Originally Posted by amahara
    aaah~

    your right, thats what i needed,
    however, can i used hyperlink instead of button to do that?


    btw thx sync_or_swim
    You're welcome, glad it helped!! With regards using a hyperlink, I dont think that is possible but one option would be to style your buttons to look like links:
    Code:
    <html>
    <style type="text/css">
      .button-link
      {
      	cursor: hand;
        border: none;
        background-color: transparent;
        text-decoration: underline;
        padding: 0;
      }
    
      .link
      {
        color: blue;
        font-size: 1em;
        font-weight: normal;
        font-family: Arial;
      }
    </style>
    
    
    <%
    If Request.Form("btnsubmit") = "Submit Form 1" Then
    	'Form 1 submitted
    Else
    	'Form 2 Submitted
    End IF
    %>
    <body>
      <table id="table1">
        <tr>
          <td>
            <form name="test1" id="test1" action="test2.asp" method="post">
              	<input id="text1" name="text1" type="Text">
              	<input type="submit" value="Submit Form 1" name="btnSubmit" class="button-link link">
            </form>
          </td>
        </tr>
      </table>
      <br>
      <hr>
      <br>
      <table id="table2">
        <tr>
          <td>
            <form name="test2" id="test2" action="test2.asp" method="post">
              	<input id="text2" name="text2" type="text">
             	<input type="submit" value="Submit Form 2" name="btnSubmit" class="button-link link">
            </form>
          </td>
        </tr>
      </table>
    </body>
  12. #7
  13. No Profile Picture
    Registered User
    ASP Explorer (0 - 99 posts)

    Join Date
    Jul 2009
    Posts
    4
    Rep Power
    0
    lol, and here i am thinking that making it into hyperlink would
    make it simpler

    i guess i'll stick to the button then

    thx again sync_or_swim
  14. #8
  15. Contributing User
    ASP High Scholar (3500 - 3999 posts)

    Join Date
    Mar 2006
    Location
    South Wales
    Posts
    3,674
    Rep Power
    2043
    Originally Posted by amahara
    lol, and here i am thinking that making it into hyperlink would
    make it simpler

    i guess i'll stick to the button then

    thx again sync_or_swim
    You're welcome, glad it helped!!

Similar Threads

  1. Override request.form value
    By loolweb in forum ASP Development
    Replies: 9
    Last Post: December 7th, 2006, 08:19 AM
  2. Writing to a text file
    By Adam_Hawkins in forum ASP Development
    Replies: 5
    Last Post: November 27th, 2006, 04:31 AM
  3. Dynamically Build SQL statement
    By rcpete39 in forum ASP Development
    Replies: 5
    Last Post: January 15th, 2005, 07:50 PM
  4. Request.Form
    By Thalandor in forum ASP Development
    Replies: 1
    Last Post: September 23rd, 2004, 10:45 PM
  5. File Uploading and Request.Form
    By jhilgeman in forum ASP Development
    Replies: 3
    Last Post: July 14th, 2004, 11:00 AM

IMN logo majestic logo threadwatch logo seochat tools logo