魏长东

weichangdong

dwz php实现下拉菜单联动

直接上代码。

<select id="uiver" name="uiver" class="combox required"  ref="account_id" refUrl="/?act=Rule.changeAccountId&uiver={value}">
                    <option value="100">主版本</option>
                    <option value="400">lite版</option>
                    <option value="500">IOS版</option>
                    
             </select>
                
                <select id="account_id" class="combox required" name="account_id">
                    <option value="0">不选择</option>
                    <{foreach from=$user_account_id item=id}>
                    	<option value="0">不选择</option>
                    	<option value="<{$id}>"><{$all_account_ids[$id]}></option>
                    <{/foreach}>
                </select>

后台php代码

public  function changeAccountId()
	{
	    $uiver = HttpUtil::getQueryData('uiver')?HttpUtil::getQueryData('uiver'):0;
	    $info = $this->getAllAccountIds($uiver);
	    $text = '[';
	    $num = count($info);
	    $n = 1;
	    foreach ($info as $key => $v)
	    {
	        if ($n == $num) {
	           $text .= '['.$key.', "'.$v.'"]';
	        } else {
	            $text .= '['.$key.', "'.$v.'"],';
	        }
	        $n++;
	    }
	    $text .= ']';
	    $text = trim($text,',');
	    exit($text);
	}