I thought I posted this earlier, but apparently it didn’t go through…
I wanted to put together a complete example for you. I am glad I did, as it turned out that the two submit buttons created a bigger wrinkle than I had originally realized.
One issue that I hadn’t considered is that once the buttons are disabled, they no longer are included in the post. This means that I was on the right track, but unfortunately my original suggestion was lacking some critical components. I apologize for this.
Below you should find a full working example of how to implement a javascript solution, based on my previous post. When javascript is enabled on the client’s browser, the buttons will be immediately disabled upon clicking on one and they will re-enable after the post is completed.
There are a few caveats to doing this, as you will see.
First, you will need to create an extra input with a type = hidden.
Second, depending on whether javascript is enabled, your post will either include a variable “sub” with the value of the clicked button, or the actual button name and value when javascript is disabled.
Since the example posts extremely fast on my server, I cannot actually see the buttons being disabled. To demonstrate that it does work, you can set the return value in the script to false. This will prevent the form from posting, but you will see that the buttons are being disabled when javascript is enabled in the browser.
Again, I apologize for my prior oversight and hope that this example is of use. Should you decide that this is not the approach you wish to take, I would be happy to try to help you come up with a more server sided solution. The benefit of the method I illustrate is that it is very efficient and relatively easy to implement. The downside to it is that not everyone will have javascript enabled.
Please let me know if you have any questions, or if this test script doesn’t work as intended.
jay[php]
POST Button Disable Demonstratrion
<?php
if(!empty($_POST['sub'])) $choice = $_POST['sub'];
elseif(!empty($_POST['like'])) $choice = 'Like';
elseif(!empty($_POST['dislike'])) $choice = 'Dislike';
if($choice=='Like') echo 'You like me! You really like me!';
if($choice=='Dislike') echo 'What did I ever do to you?';
?>
[/php]