0
我有以下php
脚本现在我希望把他的剧本在zend forms
这里是我到目前为止的代码: -如何把复选框下窗体Zend框架
$parents = array();
$childs = array();
foreach ($this->Tagkey as $aResultDataValue) {
$parents [$aResultDataValue['parent']] = $aResultDataValue['parent'];
$childs [$aResultDataValue['parent']][] = $aResultDataValue['child'];
}
foreach ($parents as $parent) {
echo '<div>';
$parent_value = "'$parent'";
echo '<div><input type="checkbox" name="parents[]" value="'.$parent.'" id="'.$parent.'" class="parentCheck"/>
<label for="parents_'.$parent.'">'.$parent.'</label></div>';
foreach ($childs[$parent] as $child) {
$child_value = "'$child'";
echo '<div style="margin-left:15px;"><input type="checkbox" name="childs[]" value="'.$child.'" id="childs_'.$child.'" class="child_'.$parent.'" onclick="checkParent('.$parent_value.','.$child_value.');"/>
<label for="childs_'.$child.'">'.$child.'</label></div>';
}
echo '</div>';
}
也是我在这里使用了一些javascript
代码
<script>
jQuery(document).ready(function(){
// add multiple select/deselect functionality
jQuery(".parentCheck").click(function() {
var childId = jQuery(this).attr('id');
jQuery('.child_'+childId).attr('checked', this.checked);
});
});
function checkParent(parentId,childId) {
if(jQuery(".child_"+parentId).length == $(".child_"+parentId+":checked").length) {
$('#'+parentId).attr("checked", "checked");
} else {
$('#'+parentId).removeAttr("checked");
}
}
</script>
这工作适合我在.phtml
网页,但实际上我希望把这个代码zend form
并呼吁这样
echo $this->form ;
我能做些什么?
注: - 在这里Tagkey是: -
$tags =new Campaign_Model_DbTable_Tag();
$aResultData = $tags->getTagkey();
$this->view->Tagkey = $aResultData;
:)我在这里使用jquery点击功能 – John 2012-01-30 13:00:14
您可以再次使用不同类别的点击功能。你不是试试吗? :P – 2012-01-30 13:04:49
:)可以YOu请给我更多的解释,我尝试子表单,但不能得到我想要的 – John 2012-01-31 04:32:36