Monitors the input box in real time to realize the interaction between the input box and the drop-down box. The input box
Html code
<Tr> <th scope = "row"> reward type: </th> <td> <input value = "" type = "text" name = "item" id = "reward" style = "width: 60px; height: 20px; "placeholder =" input keyword "/> <select name =" reward_id "id =" reward_id "> <option value =" "> --- select --- </option> {foreach $ reward as $ value} <option value = "{$ value ['material _ id']}" >{$ value ['material _ name']} </option> {/ foreach} </select> </td> </tr>
JQuery code
<script type="text/javascript"> $('#reward').bind('input propertychange', function() {reward();}); function reward() { var search = $("#reward").val(); $.ajax({ type:"get", url:"/mall/config_commodity_info/search_commodity_info", data:{search:search}, success:function(select){ var reward_id = $("#reward_id"); if (select) { $("option",reward_id).remove(); var obj = JSON.parse(select); for (var key in obj) { var option = "<option value='"+key+"'>"+obj[key]+"</option>"; reward_id.append(option); } } } }); } </script>
PHP code
public function add_alms(){ $reward = $this->materials->selReward(); $this->assign('reward',$reward); return $this->fetch();}public function do_add_alms(){ $data = Request::instance()->param(); $this->alms->addAlms($data);}
In the preceding real-time monitoring input box, the example linking the input box with the drop-down box is all the content shared by Alibaba Cloud. I hope you can provide a reference and support for the customer's house.