js div隐藏和显示
HTML代码
<tr><td>
<p class="short-input staff ue-clear">
<label>公司类型:</label>
<select class="l-select" onchange="cascadetype(this)" data-sub="公司名称,companyname" name="enterprisetype" id="enterprisetype" style="height:28px;">
<?php echo Ousuclass::all_html_option($companytypelist,'name');?>
</select>
</p></td>
</tr>
<div id="SG" style="display:none;">
<table >
<tr><td>
<p class="short-input staff ue-clear">
<label>分包项目:</label>
<input name="projectname" id="projectname" style="height:28px;"/>
<span><em>*</em></span>
</p></td><td>
<p class="short-input staff ue-clear">
<label>造价(万元):</label>
<input name="constructcost" id="constructcost" style="height:28px;"/>
<span><em>*</em></span>
</p></td>
</tr>
</table>
</div>
js代码
function cascadetype(obj)
{
var traget=document.getElementById("SG");
if(obj.value == '<?php echo $SG;?>')
{
traget.style.display = '';
}
else
{
traget.style.display = 'none';
}
}
PHP代码
<?php
$query = $this->mydb->find("select * from dictdatas where type = 'companytype'");
$data['companytypelist'] = $query['obj'];
$data['SG'] = '施工单位';
?>