how to validate the radio buttons. at least one options is selected.
code:
in this code it will display a question and 3 answers as radio buttons from a database.
for example
user has to select a correct answer. if the user not selecting any answer and click submit, I want to show a message "please select answer the question".?
how to do it?
can we use javascript?
code:
Code:
<?php
$today=date("Y-m-d");
mysql_query("SET CHARACTER SET utf8");
echo "<form method='post' id='submit' action='checkresult.php' dir='rtl'>";
$sql="SELECT * FROM cquestions where showdate='$today' limit 1";
$result=mysql_query($sql);
while ($row = mysql_fetch_array($result)) {
echo "<p>" . $row['cqtext'] . "</p>";
$sql2="SELECT * FROM canswers where cqid=".$row['cqid'];
$result2=mysql_query($sql2);
while($row2=mysql_fetch_assoc($result2))
{
echo "<input type='radio' id='a' name='".$row['cqid']."' value='".$row2['cqans']."' />".$row2['aatext'];
echo"<br>";
}
}
echo"<br>";
echo"<br>";
echo"<br>";
echo "<div align='left' style='padding-left:160px;'>";
echo"<input type='submit' id='submit' name='submit' value='التالي' />";
echo "</div>";
echo "</form>" ;
?>
for example
Code:
what is Captial of India? O New Delhi O Chennai O Mumbai
how to do it?
can we use javascript?
Comment