how to check if there is one selected radio button among the group?

Posted by assehj on Stack Overflow See other posts from Stack Overflow or by assehj
Published on 2012-03-19T12:27:30Z Indexed on 2012/03/19 18:03 UTC
Read the original article Hit count: 155

Filed under:

Good day... I am here again to ask your idea on solving this problem. I have displayed questions using while loop. Each questions have 5 radio buttons each. The problem is, I have to check if one among the group of radio button is clicked. How to do this one using php or javascript? I have here my sample program.. Thanks in advance...

$ctr = 1;
$partIDTemp = "";
while($rowItems = mysql_fetch_array($resultItems)){                          
   if( $partIDTemp != $rowItems['partID'] ){
      if($ctr != 1)
         echo "<tr ></tr>";
         echo "<tr style='font-family: Arial, Helvetica, sans-serif; font-weight:bold'><td colspan='3'>" . $rowItems['description'] . "</td></tr>";
   }
echo "<tr bgcolor=white style='font-family: Arial, Helvetica, sans-serif;'><td align='center'>" . $ctr . "</td>";
$rows =$rowItems['WPID'];
echo "<td>" . $rowItems['descriptions']. "</td>";
$response = "response_".$rows;
echo "<td><input type='radio' name='$response' value='5' />
      <input type='radio' name='$response' value='4' />
      <input type='radio' name='$response' value='3' />
      <input type='radio' name='$response' value='2' />
      <input type='radio' name='$response' value='1' />
  </td>";
$ctr++;
$partIDTemp = $rowItems['partID'];
}                            

© Stack Overflow or respective owner

Related posts about php