jquery 下拉框值对应的id,赋到前面input中

html代码:

        <tr>
                <td>
                    <p class="short-input ue-clear">
                        <label>安监员ID:</label>
                        <input type="text" id="saferid" name="saferid" readonly/>
                    </p>
                </td>
                <td>
                    <p class="short-input ue-clear">
                        <label>安监员姓名:</label>
                        <select class="l-select" name="safername" id="safername">
                            <?php echo Ousuclass::all_html_option($saferofferlist,'id', 'fullname') ?>
                        </select>
                        <span><em>*</em></span> //*号标记
                    </p>
                </td>
           </tr>

jquery代码

 $("select[name=safername]").change(function(){
            $("input[name=saferid]").val($("select[name=safername]").val());
        })

后台php代码

<?php

public function getSafetyOfficerList()
    {
        $sql = "select * from sysusers where accounttype = '安监员' and isenable = 'Y'";
        $query = $this->db->query($sql);
        return $query->result_array();
    }

$data['saferofferlist'] =$this->getSafetyOfficerlist()

?>

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

导航