I am looking to create an average of the answers submitted by visitors using radio buttons. I have a simple script to work out an average but do not seem to be able to apply it to my form, the frustrating thing is I'm sure I am close with my efforts but that counts for nothing if you dont get the end result you want lol >>
Code: Select all
<body>
<form action="age.php" method="post" name="ageform">
<label>1
<input type="radio" name="ageform" id="radio" value="19" onclick="this.form.submit();"/>
</label>
<label>2
<input type="radio" name="ageform" id="radio" value="20" onclick="this.form.submit();"/>
</label>
<label>3
<input type="radio" name="ageform" id="radio" value="21" onclick="this.form.submit();"/>
</label>
</form>Code: Select all
<?
$currentage = 7;
$sum = $currentage + $ageform;
$result = $sum/2;
echo($result);
?>