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 Coder
    Join Date
    Jan 2004
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    explicitly post a data

    my situation is like this:

    <form action="test.php" method=post>
    <input type=text name=txtTo>
    <input type=text name=txtMessage>
    <input type=button name=btnSend1 value=Send>
    <input type=button name=btnSendAll value="Send to All">
    </form>

    i know how to make a button call a javascript function to submit the form...but i want to make those to buttons to be able to do that but with a different effect...

    if the user click on the btnSend1 button, it will send the datas to test.php like normal. When btnSendAll is click, it will send to test.php with an extra data to let the system know that the user click btnSendAll instead of btnSend...

    How can i do that, is there a way for me to post an extra data when the data is not from the <form>'s tag???

    Do you all understand? What i'm typing here is kinda messy, isnt it?

    hehe....thanks in advance though...
    Warm Regards,
    Jacky

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Make the buttons submit buttons so that the value of the clicked button is also part of the form data and sent to the server.

    <input type="submit" name="btnSend1" value="Send">
    <input type="submit" name="btnSendAll" value="Send to All">

  • #3
    New Coder
    Join Date
    Jan 2004
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    so how do i check which button has been click using php?
    Warm Regards,
    Jacky

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Posts
    698
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
     
    <?
    if(!isset($btnSend))
    {
    ?>
    <form name=form1 action="test.php" method=post>
    <input type=text name=txtTo>
    <input type=text name=txtMessage>
    <input type=button name=btnSend value=Send>
    <input type=button name=btnSend value="Send to All">
    </form>
    <?
    }else
    {
      switch($btnSend )
      {
         case 'Send':
         {
    
          break;
         } 
         case 'Send to All':
         {
    
          break;
         }  
      }
    }
    
    ?>

  • #5
    New Coder
    Join Date
    Jan 2004
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    got it, thanks a thousand man...
    Warm Regards,
    Jacky


  •  

    Posting Permissions

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