问问题
135 次
3 回答
0
echo "<tr><td>Product Category* </td>";
echo "<td>";
echo "<select size=\"1\" name=\"pc\" id=\"pc\">";
echo "<option value=\"0\">Product Category</options>";
echo "<option value=\"77-Hair\">Hair</options>";
echo "<option value=\"88-Skin\">Skin</options>";
echo "<option value=\"99-Nail\">Nail</options>";
echo "<option value=\"66-Eyes\">Eyes</options>";
echo "</select></td>";
并在服务器端拆分“-”的值
于 2013-08-11T13:14:47.100 回答
0
万一,你不明白Juhana
他的评论,这就是他的意思。
echo "<td>";
echo "<select size=\"1\" name=\"pc\" id=\"pc\">";
echo "<option value=\"0\">Product Category</options>";
echo "<option value=\"77\">Hair</options>";
echo "<option value=\"88\">Skin</options>";
echo "<option value=\"99\">Nail</options>";
echo "<option value=\"66\">Eyes</options>";
echo "</select></td>";
但是,如果您想通过 JS / jQuery 解决方案执行此操作。
jQuery
$(function() {
$('#pc').change(function() {
var cat_id = $('option:selected', this).data(category_id);
$('#cat_id').val(cat_id);
});
});
PHP
echo "<td>";
echo "<select size=\"1\" name=\"pc\" id=\"pc\">";
echo "<option value=\"0\">Product Category</options>";
echo "<option data-category_id=\"77\" value=\"Hair\">Hair</options>";
echo "<option data-category_id=\"88\" value=\"Skin\">Skin</options>";
echo "<option data-category_id=\"99\" value=\"Nail\">Nail</options>";
echo "<option data-category_id=\"66\" value=\"Eyes\">Eyes</options>";
echo "</select></td>";
echo "<input type=\"hidden\" id=\"cat_id\" name=\"category_id\" />";
于 2013-08-11T13:05:47.530 回答
0
为什么你不把这些 id 的价值?
echo "<tr><td>Product Category* </td>";
echo "<td>";
echo "<select size=\"1\" name=\"pc\" id=\"pc\">";
echo "<option value=\"0\">Product Category</options>";
echo "<option value=\"77\">Hair</options>";
echo "<option value=\"88\">Skin</options>";
echo "<option value=\"99\">Nail</options>";
echo "<option value=\"66\">Eyes</options>";
echo "</select></td>";
于 2013-08-11T13:09:00.577 回答