我正在使用多选来获取一些值。这个多选使用的是 Chosen jQuery 插件。
出于某种原因,在 PHP 中,此多选返回所有值,而不仅仅是选定的值。
的HTML
<select name="taglist[]" size="10" id="taglist" style="width:350px;" class="chzn-select" multiple multiple-data-placeholder="Select some tags" >
**This is populated by Ajax**
</select>
阿贾克斯人口之后
<option value="Student community of reflection - A conscious environment of cooperative sharing of ideas and proces">Student community of reflection - A conscious environment of cooperative sharing of ideas and proces</option>
<option value="Teacher inclusive conversations - Emphasis on a sharing of power with students; visibility that enco">Teacher inclusive conversations - Emphasis on a sharing of power with students; visibility that enco</option>
<option value="Teacher feedback - Awareness of the power of written, oral and symbolic feedback on students self co">Teacher feedback - Awareness of the power of written, oral and symbolic feedback on students self co</option>
<option value="Student self assessment ( metacognitive reflection) - Continuous opportunities for students to thin">Student self assessment ( metacognitive reflection) - Continuous opportunities for students to thin</option>
PHP的
foreach ($_REQUEST['taglist'] as $value)
{
mysql_query("INSERT INTO recent_tags (t_name, t_owner, t_post) VALUES ('$value', '$uid', '$id')") or die (mysql_error());
}
结果
Array ( [0] => 学生反思社区 - 有意识地合作分享想法和过程的环境 [1] => 教师包容性对话 - 强调与学生分享权力;可见性 [2] => 教师反馈- 意识到书面、口头和符号反馈对学生自我合作的力量 [3] => 学生自我评估(元认知反思) - 学生不断有机会瘦身)
即使在多选框中仅选择了其中一个选项,也会发生这种情况
希望有人能够帮助解决这个问题,这让我很头疼。
print_r($_POST) 的结果
Array ( [entry_name] => aaa [entry_content] => [tag_category] => Insider Classroom Framework [taglist] => Array ( [0] => Student community of reflection - A conscious environment of cooperative sharing of ideas and proces [1] => Teacher inclusive conversations - Emphasis on a sharing of power with students; visibility that enco [2] => Teacher feedback - Awareness of the power of written, oral and symbolic feedback on students self co [3] => Student self assessment ( metacognitive reflection) - Continuous opportunities for students to thin ) [button] => Post )
表格帖子
<form id="form1" name="form1" method="post" onSubmit="return checkAll();" action="process/webpl_journal_entry_process.php">