Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    button identification??

    I have 3 buttons on the page and each has type of submit.So how we can identify on other page which one button is clicked??

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,033
    Thanks
    203
    Thanked 2,539 Times in 2,517 Posts
    Quote Originally Posted by wisemind85 View Post
    I have 3 buttons on the page and each has type of submit.So how we can identify on other page which one button is clicked??
    Cookie.

    Within the same page:-

    Code:
    <script type="text/javascript">
    var buttn;
    function whichBtn(frm) {
    alert(buttn);
    return false;
    }
    </script>
    
    <form name = "myform" onsubmit="return whichBtn(this)">
    <input type="image" src="http://www.codingforums.com/images/buttons/reply.gif" border="0" name="Post Reply" onclick="buttn=this.name">&nbsp;&nbsp;
    
    <input type="image" src="http://www.codingforums.com/images/buttons/quote.gif" border="0" name="Quote"  onclick="buttn=this.name">
    </form>

    He thought he saw a Garden-Door
    That opened with a key:
    He looked again, and found it was
    A Double Rule of Three:
    "And all its mystery," he said,
    "Is clear as day to me!"
    - Lewis Carroll

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,858
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    So how we can identify on other page which one button is clicked??
    Code:
    <form name = "myform" method="get">
    <input type="submit" name="Reply" value="Reply" >&nbsp;&nbsp;
    
    <input type="submit"  name="Quote"   value="Quote">
    </form>
    Check the url after submitting a form like above.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #4
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well the thing that i want is.

    I have 3 buttons with ids b1,b2,b3

    <form name='form1' action='abc.jsp'>
    <input type='Submit' value='b1' id='b1'/>
    <input type='Submit' value='b2' id='b2'/>
    <input type='Submit' value='b3' id='b3'/>

    </form>

    So i want to get the value of button on jsp page using javascript that which one button was clicked,Do you think i have to define some hidden variable?? Any solution??

  • #5
    Regular Coder
    Join Date
    Feb 2009
    Location
    Wheeling, IL
    Posts
    358
    Thanks
    5
    Thanked 62 Times in 60 Posts
    You don't have to define any hidden variables. Just add a name to the submits the way abduraooft suggested as well as changing the form method to get, you can even go as far as to give them all the same name. example:

    Code:
    <form name='form1' action='abc.jsp' method="get">
        <input type='Submit' value='b1' id='b1' name="which"/>
        <input type='Submit' value='b2' id='b2' name="which"/>
        <input type='Submit' value='b3' id='b3' name="which"/>
    </form>
    After that... getting the value from JSP shouldn't be all that hard:

    Code:
    <%
        String which = request.getParameter("which");
    %>
    After that... just do whatever with the variable which (that contains the value of the clicked button). I don't see where the problem is with the offered solutions.


  •  

    Posting Permissions

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