[英]Multiple Forms and Radio Buttons
我是在測驗軟件中進行設計的,其中問題以試卷的形式列出。 用戶假設只回答一個問題,一個回答。 我的問題是,對於每個問題和3個選項,我都有不同的表格。 一旦我提交,我想知道以各種形式選中了哪個單選按鈕。 代碼是這樣的。
<html>
<form name="one" action="me.php" method="post">
<input type="radio" name=" subject " value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="submit" value="submit">
</form>
<form name="one" action="me2.php" method="post">
<input type="radio" name=" subject " value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="submit" value="submit">
</form>
<form name="one" action="me3.php" method="post">
<input type="radio" name=" subject " value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="submit" value="submit">
</form>
<form name="one" action="me4.php" method="post">
<input type="radio" name="subject" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="radio" name="options" value="some thing">
<input type="submit" value="submit">
</form>
</html>
謝謝
像這樣,不要使用多種形式,
<html>
<form name="one" action="me.php" method="post">
<input type="radio" name="subject_dbid" value="some thing">
<input type="radio" name="options_dbid" value="some thing">
<input type="radio" name="options_dbid" value="some thing">
<input type="radio" name="options_dbid" value="some thing">
<input type="radio" name="subject_dbid" value="some thing">
<input type="radio" name="options_dbid" value="some thing">
<input type="radio" name="options_dbid" value="some thing">
<input type="radio" name="options_dbid" value="some thing">
<input type="submit" value="submit">
</form>
</html>
dbid
是您的數據庫。
確保dbid
是您問題的ID。(主題和選項應相同)。
對於第一個問題,您的文章都會有, subject_1
和option_1
將有選擇的問題。
要訪問php中的問題和答案,請在php中將explode()
與_
一起使用。
$arr[1]
將具有數據庫ID。 您可以輕松地將答案與數據庫匹配。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.