Something similar to this should work...
$('form').submit(function(e) {
e.preventDefault();
$.post($(this).attr('action'), $(this).serialize(), function(response) {
// ... parse response
});
});
質問
i have a html form code
$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;
now what i want is a js/jquery function that will serialize the radio buttons then pass it through the db w/out using the submit button, maybe like ajax or whatever..
can someone help me with this.. i really need it soon .. thank you :D
正しい解決策はありません
他のヒント
Something similar to this should work...
$('form').submit(function(e) {
e.preventDefault();
$.post($(this).attr('action'), $(this).serialize(), function(response) {
// ... parse response
});
});