I’m using a multiselect to get some values. This multiselect is using Chosen jQuery plugin.
For some reason in PHP this multiselect is returning all the values, not just the selected ones.
The 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>
After Ajax population
<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>
The 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());
}
The Result
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 )
This is happening even though only 1 of these options was selected in the multiselect box
Hope somebody will be able to help with this, its doing my head in.
Result of 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 post
<form id="form1" name="form1" method="post" onSubmit="return checkAll();" action="process/webpl_journal_entry_process.php">
I think your HTML is off. You have:
And I can’t see how your ‘inner-check-boxes’ look, but I am almost certain that you don’t have them as
name='taglist[]', where as you want them to carry that value, and you don’t want your selectnameto betaglist[].If you are using a list, then you want to keep the select name as
taglist[], but don’t want to name any inner-option, just have theirvalue‘s.EDIT:
All code displayed, and works fine: