這是HTML代碼我已經使用下拉形式...
/addProduct命令」是enctype = '的multipart/form-data的'>
<fieldset>
<legend>Category Information</legend>
<div class="required">
<label for="category">Main Category
<font color="red" title="This field is required for registration.">*</font></label>
<?php if(isset($merchantData->membership_package) && $merchantData->membership_package==2)
$categoryId=1;
if(isset($categoryId) && $categoryId!='')
$whereCondition="category_id='".$categoryId."' && is_active='1' && parent_id='0' order by category_name";
else
$whereCondition="is_active='1' && parent_id='0' order by category_name";
?>
<?php
echo $obj_category->selectBox('cat_id', 'Select Category', 'category_id', 'category_name', isset($cat_id) ? $cat_id :"",$whereCondition, 'class="validate[required]"');
?>
<div class="clear"></div>
<small>Please select the best combination of category and sub-categories for your product</small>
</div>
<div class="required">
<label for="sub_category">Sub Category<font color="red" title="This field is required for registration.">*</font></label>
<?php
if (isset($cat_id) && !empty($cat_id)) {
echo $obj_category->selectBox('subcat_id', 'Select Sub Category', 'category_id', 'category_name',
isset($ subcat_id)? $ subcat_id:'',「is_active ='1'和parent_id ='」。 $ cat_id。 「'order by category_name」,'class =「validate [required]」');
} else {
?>
<select name="subcat_id" id="subcat_id" title="Sub Category" class="validate[required]">
<option>Select Sub Category</option>
</select>
<?php } ?>
<div class="required">
<label for="sub_sub_category">Sub Sub Category<font color="red" title="This field is required for registration.">*</font></label>
<?php
if (isset($subcat_id) && !empty($subcat_id)) {
echo $obj_category->selectBox('subsubcat_id', 'Select Sub Sub Category', 'category_id', 'category_name', isset($subsubcat_id) ? $subsubcat_id : '', "is_active = '1' and parent_id ='" . $subcat_id . "' order by category_name", 'class="validate[required]"');
} else {
?>
<select name="subsubcat_id" id="subsubcat_id" title="Sub Sub Category" class="validate[required]">
<option>Select Sub Sub Category</option>
</select>
<?php } ?>
</div>
</fieldset>
來源
2014-10-20 15:58:53
sam
感謝您的答覆。我試過這個,但它不工作。 cat_id不會改變,它仍然接收空值。如果cat_id被改變,那麼只有改變函數纔會被觸發。我不知道該怎麼做...... – sam 2014-10-20 15:34:20
你能發佈你的html嗎?更改功能是不是你想要觸發的唯一的事情? – 2014-10-20 15:40:06
我想在更改cat_id時觸發更改功能。但是,當我選擇主類別值時,cat_id沒有收到任何值。 – sam 2014-10-20 19:54:36