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