Forum Moderators: open
<?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.
Hi dkin,I think I see what you are trying to do.
Try changing this line:
if ($submit){
to: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