Javascript 多种表单和单选按钮
我设计了一个问答游戏,其中的问题以问题纸的形式排列。用户假设只回答一个问题和一个答案。我的问题是,对于每个问题和3个选项,我有不同的形式。一旦我提交,我想知道哪个单选按钮是选中的各种形式得到提交。代码是这样的Javascript 多种表单和单选按钮,javascript,php,html,Javascript,Php,Html,我设计了一个问答游戏,其中的问题以问题纸的形式排列。用户假设只回答一个问题和一个答案。我的问题是,对于每个问题和3个选项,我有不同的形式。一旦我提交,我想知道哪个单选按钮是选中的各种形式得到提交。代码是这样的 <html> <form name="one" action="me.php" method="post"> <input type="radio" name=" subject " value="some thing"> <input type=
<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。(主题和选项的id应该相同。)
对于第一个问题,您的帖子将有,subject\u 1
和option\u 1
将为问题选择答案
要访问php中的问题和答案,请在php中使用explode()
和
$arr[1]
将具有数据库id。您可以轻松地将答案与数据库匹配。为什么要采用多种形式?试试isset()
。顺便说一句,请注意name=“subject”
中的空格,它们算作空格。感谢您识别空格字符。我的要求是“用户假设只回答一个问题和一个答案”,并且每个问题的回答都被发送到单独的页面以执行其他计算。谢谢您,先生。我的要求是“用户假设只回答一个问题和一个答案。”“每个问题的回答都会被发送到单独的页面,以便执行其他计算,而您每次只会显示一个问题??