Running a php function via a form submit onclick event

Discussion in 'JavaScript' started by stauf, Jun 24, 2007.

  1. #1
    The title kinda says it all. I have a form with a php backend to setup data for processing to paypal, but I need to run a php function when the user clicks the buynow button. I still need the button to post to paypal and xfer, but I need a secondary php function run as well. Anyone have ideas or suggestions? Thanks!
     
    stauf, Jun 24, 2007 IP
  2. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #2
    what that php function should do? normally you can't run php method on a button, only js method.
     
    gibex, Jun 24, 2007 IP
  3. stauf

    stauf Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hmm. I just need to activate a counting function that writes to a log. Guessing I'm sol on this one.
     
    stauf, Jun 24, 2007 IP
  4. UnrealEd

    UnrealEd Peon

    Messages:
    148
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    use AJAX. with AJAX you can send requests to serversided pages without having to refresh/submit the form. Just google around a bit, and you'll find some scripts.

    It's not very difficult, and always looks very nice on a website
     
    UnrealEd, Jun 24, 2007 IP
  5. DeViAnThans3

    DeViAnThans3 Peon

    Messages:
    785
    Likes Received:
    83
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Indeed, definitely go for AJAX. It does exactly what you're looking for.
    You'll have to write a specific part of PHP code for it too (in fact just the function), but I think you can certainly handle that lol
     
    DeViAnThans3, Jun 24, 2007 IP
  6. stauf

    stauf Peon

    Messages:
    21
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Isn't Ajax something I used to use to clean the kitchen with? lol

    Thanks guys, I'll have a look into it and hopefully won't pass out in the process. ;P
     
    stauf, Jun 24, 2007 IP
  7. gibex

    gibex Active Member

    Messages:
    1,060
    Likes Received:
    21
    Best Answers:
    0
    Trophy Points:
    95
    #7
    gibex, Jun 24, 2007 IP