Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/258.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 多种表单和单选按钮_Javascript_Php_Html - Fatal编程技术网

Javascript 多种表单和单选按钮

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=

我设计了一个问答游戏,其中的问题以问题纸的形式排列。用户假设只回答一个问题和一个答案。我的问题是,对于每个问题和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。(主题和选项的id应该相同。)

对于第一个问题,您的帖子将有,
subject\u 1
option\u 1
将为问题选择答案

要访问php中的问题和答案,请在php中使用
explode()


$arr[1]
将具有数据库id。您可以轻松地将答案与数据库匹配。

为什么要采用多种形式?试试
isset()
。顺便说一句,请注意
name=“subject”
中的空格,它们算作空格。感谢您识别空格字符。我的要求是“用户假设只回答一个问题和一个答案”,并且每个问题的回答都被发送到单独的页面以执行其他计算。谢谢您,先生。我的要求是“用户假设只回答一个问题和一个答案。”“每个问题的回答都会被发送到单独的页面,以便执行其他计算,而您每次只会显示一个问题??