Forum Moderators: coopster
<?php
if ($submit){
$score = '7';
$vote_amount = '15152';
$vote_total = '109100';
$answer = ($score + $vote_total) / ($vote_amount + '1');
print 'Your average is '. $answer . ' with '. $vote_amount .' votes.';
}
print '<form action='.$PHP_SELF.' method="post">'
. '1 <input type="radio" name="score" value="1" onClick="this.form.submit()"/>'
. '2 <input type="radio" name="score" value="2" onClick="this.form.submit()"/>'
. '3 <input type="radio" name="score" value="3" onClick="this.form.submit()"/>'
. '4 <input type="radio" name="score" value="4" onClick="this.form.submit()"/>'
. '5 <input type="radio" name="score" value="5" onClick="this.form.submit()"/>'
. '6 <input type="radio" name="score" value="6" onClick="this.form.submit()"/>'
. '7 <input type="radio" name="score" value="7" onClick="this.form.submit()"/>'
. '8 <input type="radio" name="score" value="8" onClick="this.form.submit()"/>'
. '9 <input type="radio" name="score" value="9" onClick="this.form.submit()"/>'
. '10 <input type="radio" name="score" value="10" onClick="this.form.submit()"/>'
. '</form>';
?>
And I would like the if statement to be triggered when a radio button is clicked. How do I do that?
Thanks all.
p.s. This is the best webmaster forum on the net, blows devshed, sitepoint and all that other garbage out of the water. I used to use devshed all the time but I could never get a decent ansewr to any questions they would all just taunt me because I was new, so I tried here. Havent posted on any other forums since. Thanks Webmaster world. :D
but I could never get a decent ansewr to any questions they would all just taunt me because I was new, so I tried here. Havent posted on any other forums since.
We are all here to help and learn from each other. Making fun and taunting people is not what we are about. :)
You might want to try this in the javascript section as this cannot be accomplished by using PHP. PHP cannot perform any client side actions.
Good luck!
dc :)
I think I see what you are trying to do.
Try changing this line:
if ($submit){ if ($_SERVER['REQUEST_METHOD'] == 'POST') { This should make it so that the code inside the if statement is called after the form is submitted.
I'm glad you like WebmasterWorld. :)
Post back if you need more help. ;)
Elijah