我有一个html表单代码
$resulta = mysql_query("SELECT * FROM tblquestions WHERE subject = '".$subject."' ORDER BY rand()"); // dahil dyan, nag erro ung counting ng tamang sagot
$tbl="";
$tbl = '<form action="" method="POST" > ';
$tbl .='<fieldset style="border: 2px solid grey; border-radius:7px; -moz-box-shadow:0 0 8px #666; -webkit-box-shadow:0 0 8px #666; box-shadow:0 0 8px #666;">';
$tbl .='<table width ="100%" height="100%" style="border: 2px solid grey; " >';
while( $row = mysql_fetch_array($resulta))
{
$tbl .= "<tr style='border: 2px solid grey;'>";
$tbl .= "<td style='border: 2px solid grey; font-weight:bold;'>Question # " .$countme."</td>";
$tbl .="<td colspan='3' style='border: 2px solid grey; font-weight:bold;'>".$row['Questions']."</td>";
$tbl .="</tr>";
// line /
$troll= 'QID'. $countme; //name for radio button e.g. QID1,QID2 to get right answers
$tbl .="<tr style='border: 2px solid grey;'>";
$tbl .="<td style='border: 2px solid grey;' ><label><input type='radio' name='".$troll."' value='".$row['choice4']."'>".$row['choice4']."</label></td>";
$tbl .="<td style='border: 2px solid grey;'><label><input type='radio' name='".$troll."' value='".$row['choice2']."'>".$row['choice2']."</label></td>";
$tbl .="<td style='border: 2px solid grey;'><label><input type='radio' name='".$troll."' value='".$row['choice3']."'>".$row['choice3']."</label></td>";
$tbl .="<td style='border: 2px solid grey;'><label><input type='radio' name='".$troll."' value='".$row['choice1']."'>".$row['choice1']."</label></td>";
$tbl .="</tr>";
$rawr[$countme]= $row['choice4'];
$countme=$countme+1;
}
$tbl .="</table>";
$tbl .='</fieldset>';
$tbl .='<br/>';
$tbl .=' <p style="float:right">
<span class="art-button-wrapper">
<span class="art-button-l"> </span>
<span class="art-button-r"> </span>
<input type="submit" name="Submit" class="art-button" value="NEXT --> " />
</span>
</p>';
$tbl .='</form>';
echo $tbl;
现在我想要的是一个js / jquery函数,它将序列化单选按钮,然后使用提交按钮将其传递给db w / out,可能像ajax或其他..
有人可以帮我这个..我很快就需要它..谢谢你:D
答案 0 :(得分:0)
类似的东西应该有用......
$('form').submit(function(e) {
e.preventDefault();
$.post($(this).attr('action'), $(this).serialize(), function(response) {
// ... parse response
});
});