0

我有一个 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 函数,它将序列化单选按钮,然后使用提交按钮将它传递给数据库,可能像 ajax 或其他什么..

有人可以帮我解决这个问题..我真的很快就需要它..谢谢你:D

4

1 回答 1

0

类似的东西应该可以工作......

$('form').submit(function(e) {
    e.preventDefault();
    $.post($(this).attr('action'), $(this).serialize(), function(response) {
        // ... parse response
    });
});
于 2014-02-02T10:39:38.153 回答