PHP Codeigniter:在下拉列表中获取数据并填充到文本框中 [英] PHP Codeigniter: fetch data in dropdown and populate into textbox

查看:55
本文介绍了PHP Codeigniter:在下拉列表中获取数据并填充到文本框中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想说的是:当您单击下拉列表或选择时,它将获取prod_temno,prod_desc,prod_selluom的数据,然后填充到名为idesc和ventoryuom的文本框中.我希望你能帮助我.预先感谢.

What I'm trying to say is: when you click dropdown or select, it will fetch the data of prod_temno, prod_desc,prod_selluom then populate to the textbox named: idesc and inventoryuom. I hope you can help me. Thanks in advance.

 <table>
    <tr><form name="form1">
        <td>Item No:</td>
        <td>
        <select type="text" id="inventoryitemno" name="inventoryitemno" >
            <?php
                foreach($itemno as $row){
                    echo "<option id=".$row->prod_id.">".$row->prod_itemno."</option>";
                }
            ?>               
        </select>                                
        </td>
    </tr>
    <tr>
        <td>Description:</td>
        <td><input type="text" id="idesc" name="idesc"/></td>  
    </tr>
     <tr>
        <td>UOM:</td>
        <td><input type="text" id="inventoryuom" name="inventoryuom" /></td>
    </tr>

</table>

这是我的产品模型

    public function view_product_itemno(){
        $this->load->database();
        $data = $this->db->query('select prod_id, prod_itemno, prod_desc, prod_inventoryuom from product;');
        return $data->result(); 
    }

我希望这对你们来说很清楚.谢谢.

I hope this is clear for you guys. Thanks.

推荐答案

这是您想要的吗?

<?php
$itemno = array('0'=>'a','1'=>'b','2'=>'c');

?>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.1.min.js" ></script>
<table>
<tr><form name="form1">
    <td>Item No:</td>
    <td>
    <select type="text" id="inventoryitemno" name="inventoryitemno"  onchange="javascript:set_to(this.value);" >
         <?php
             foreach($itemno as $key=>$val){
                echo "<option id=".$key.">".$val."</option>";
            }
        ?>               
    </select>                                
    </td>
</tr>
<tr>
    <td>Description:</td>
    <td><input type="text" id="idesc" name="idesc"/></td>  
</tr>
 <tr>
    <td>UOM:</td>
    <td><input type="text" id="inventoryuom" name="inventoryuom" /></td>
</tr>

</table>
<script type="text/javascript">
function set_to(id)
{

    $('#idesc').val(id);
}
</script>

这篇关于PHP Codeigniter:在下拉列表中获取数据并填充到文本框中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆