button identification??

Discussion in 'JavaScript' started by wisemind85, Mar 11, 2009.

  1. #1
    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??
     
    wisemind85, Mar 11, 2009 IP
  2. bhagwant.banger

    bhagwant.banger Active Member

    Messages:
    99
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    60
    #2
    All HTML controls are identified by there name. In a single page you can press only one button at a time


    for eg..

    <input type="submit" name="add" value="Add">
    <input type="submit" name="edit" value="Edit">
    <input type="submit" name="delete" value="Delete">
    
    Code (markup):

    In the above example all the three buttons have the type as submit but
    the individual buttons are identified by there names

    if you are using php, then php captures all form controls in super global arrays
    ii.e $_POST or $_GET depending upon the method used to post the form.
    you can print the arrays with

    print_r($_GET);
    PHP:
    or
    print_r($_POST);
    PHP:
    to check what all controls have been passed through the forms


    hope this would help you
     
    bhagwant.banger, Mar 11, 2009 IP
  3. wisemind85

    wisemind85 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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??
     
    wisemind85, Mar 12, 2009 IP