Forum Moderators: open

Message Too Old, No Replies

Rating system, onclick help

         

dkin

1:53 am on Dec 14, 2004 (gmt 0)

10+ Year Member



there are many sites out there like ratemykitty.com that have a rating system that I would like,if you goto that site and click a number the form submits and moves onto the next page, this is what I have formy form but when I click any radio button it just reloads, I need it to show the results for the last vote as well.

<?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.

Elijah

1:59 am on Dec 14, 2004 (gmt 0)

10+ Year Member



Well, I've already replied to your other post but here's a copy of my reply to your other post. :)

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

dkin

2:58 am on Dec 14, 2004 (gmt 0)

10+ Year Member



thats all I needed for now, sorry for duplicate posts :D thanks.