CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Posts
    2

    How to control which button is processed?

    How to control which button is processed in JSP.

    I have a html page called "formftplogoff.htm"
    The form has two buttons:
    [Yes] and [No]
    Here is the simple form

    If the Yes button is executted it goes to a JSP page "processftplogoff.jsp" and the logging of process is executed. How can I control the second operation When "no" is pressed. If no is presses than the user is taken to page called "preferences.jsp". How can I do this?

    The book I am using shows forms with "submit" button so basically one buton action. Please help.


    <html>
    <head>
    <title> FTP Log off </title>
    <body>

    <p>Do you wish to log off from ftp server?</p>
    <FORM ACTION="processftplogoff.jsp" METHOD="get">
    <input type="button" value="Yes" name="b1">
    <input type="button" value="No" name="b2">
    </form>
    </body>
    </html>

  2. #2
    Join Date
    Jan 2002
    Location
    Halifax, NS, Canada
    Posts
    985
    I've never written anything in JSP before, but I've done a little CGI programming on Theoswww.theos-software.com. So I'll try to help.

    To get the value in JSP (Note I've never done it but..)
    Code:
    <%
       String value = request.getParameter("b1")
       if ( value == null ) {
             value = request.getParameter("b2")
        }
    %>
    What I do sometimes on THEOS, is give the same name to submit buttons. Now I know that sounds strange, but the user can only click one, so you'd have the right value. I don't know if that would work with JSP though.

    I don't even know if that would work with all CGI, Theos tends to do things a little differently.
    Last edited by Goodz13; September 25th, 2002 at 11:19 AM.

  3. #3
    Join Date
    Mar 2002
    Posts
    132
    Use two form tags instead of one like this
    Also use input type=submit
    I hope this should work

    <html>
    <head>
    <title>
    FTP Log off
    </title>
    <body>
    <p>Do you wish to log off from ftp server?</p>
    <FORM ACTION="processftplogoff.jsp" METHOD="get">
    <input type="submit" value="Yes" name="b1">
    </FORM>

    <FORM ACTION="preferences.jsp" METHOD="get">
    <input type="submit" value="No" name="b2">
    </form>
    </body>
    </html>

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured