Table categories:
id
name
parent_id
值
1 - Main Category - 0,
2 - Main Category1 - 1,
3 - Main category2 - 1,
4 - Subcategory 1 - 2,
5 - Subcategory 2 - 2
6 - Main category3 - 1
Combobox喜欢这个
Main Category
--> Main Category 1
-------->SubCategory 1
-------->SubCategory 2
--> Main Category 2
--> Main Category 3
如何???谢谢回答!
答案 0 :(得分:0)
除非您提交表单,否则您需要使用javascript。示例代码如下所示
cat1:<input type="checkbox" id="cat1"><br>
cat2:<input type="checkbox" id="cat2" onChange="fnc('subcat1','subcat2')"><br>
subcat1:<input type="checkbox" id="subcat1" style="visibility:hidden"><br>
subcat2:<input type="checkbox" id="subcat2" style="visibility:hidden"><br>
cat3:<input type="checkbox" id="cat3">
<script type="text/javascript">
function fnc(id1,id2)
{
if(document.getElementById("cat2").checked==true)
{
document.getElementById(id1).style.visibility='visible';
document.getElementById(id2).style.visibility='visible';
}
else
{
document.getElementById(id1).style.visibility='hidden';
document.getElementById(id2).style.visibility='hidden';
}
}
</script>