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'] = '施工单位';

?>

 

posted on 2015-07-17 17:16  勤奋者努力着  阅读(2760)  评论(0编辑  收藏  举报

导航