查询时,保留输入的查询内容,(以及默认选中某个下拉列表
来源:互联网 发布:游戏开发巨头复杂算法 编辑:程序博客网 时间:2024/04/29 23:35
思路:将输入的内容或选项提交给控制层,并把值赋给显示层,在显示时把默认value值输出、option默认选中。
1、控制层:
function searchinfo(){$name = $this->input->post('name'); $mobile =trim($this->input->post('mobile'));$workplace = trim($this->input->post('workplace'));$begindate = trim($this->input->post('begindate'));$comfrom =trim($this->input->post('comfrom'));$lifecity =trim($this->input->post('lifecity'));$data['name'] = $name;$data['mobile'] = $mobile;$data['workplace'] = $workplace;$data['begindate'] = $begindate;$data['comfrom'] = $comfrom;$data['lifecity'] = $lifecity;$this->load->model('student_model');$data['query'] = $this->student_model->search_student();$data['query2'] = $this->student_model->get_studentinfo();$data['query3'] = $this->student_model->get_lifecity();$data['query4'] = $this->student_model->get_comefrom(); if($data['query'] == NULL){$this->load->view('header');$this->load->view('student_search2',$data);$this->load->view('footer');}else{$this->load->view('header');$this->load->view('student_search',$data);$this->load->view('footer');}}
2、显示层
<?php $option ="<option value =''>-请选择-</option>";$select='';<span style="color:#FF0000;"> foreach ($query2 as $v){ if($v['begindate'] == $begindate){ $select="selected='selected'"; } $option = $option."<option value =".$v['begindate']." ".$select.">".$v['begindate'].'</option>'; $select = ''; }</span>?>
3、另一实例
<span style="font-size:18px;">//得到符合队伍条件的团体比赛项目public function getteameventList($matchid,$intna,$intnv,$minage){//已报项目,默认为选中状态。//查询已报项目$teamid = $_SESSION['teamid'];$sql = "select *from teamform where teamID = '$teamid' ";$query = $this->db->query($sql);$rowdata = $query->row_array();if($rowdata!=null){$checkone = $rowdata["eventID"];}else{$checkone ="";}//进行循环判断已报项目是否与下拉选项中某个选项值一样。$sql = "select eventid,eventname from events where matchid = ".$matchid." and maxna >= ".$intna." and minna <= ".$intna." and maxnv >= ".$intnv." and minnv <= ".$intnv." and minage >=".$minage;//echo $sql;$query = $this->db->query($sql);$arrdata = $query->result_array();$stroption = "";$select = '';$i = 0;if($arrdata){<span style="color:#FF0000;">foreach($arrdata as $value){</span><span style="color:#FF0000;">if($arrdata[$i]["eventid"] == $checkone ){$select="selected='selected'"; }$stroption = $stroption."<option value=\"".$value['eventid']."\"".$select.">".$value['eventname']." </option>";$select = '';$i=$i+1;}</span>}return $stroption;}</span>
0 0
- 查询时,保留输入的查询内容,(以及默认选中某个下拉列表
- 选不同下拉列表,转不同链接(以及默认选中某个下拉项
- 判断下拉列表框里的值是否与某个值相等时,默认为选中状态
- 下拉列表的赋值,和默认选中
- 【JavaScript】Select下拉列表 可输入的模糊查询
- 关于Select option默认选中及查询后选项值保留的问题
- 关于Select option默认选中及查询后选项值保留的问题
- 下拉列表默认选中--- jQuery
- java开发中select下拉列表在查询操作中保留查询条件问题
- Select下拉列表类(支持输入模糊查询)
- Select下拉列表类(支持输入模糊查询)
- list列表去除重复项以及查询某个字符串在list的出现次数
- select 动态查询时,设置某一项为默认选中
- 查询以及删除通话记录的内容
- 输入一串字符,查询某个字符出现的位置
- 下拉列表根据所选Item选中某个值
- 如何使已经有选中项的ComboBox在点击下拉箭头时,仍然默认从列表开始处显示,而不是跳到选中项的位置
- 弹出下拉编辑控件,跟踪输入内容自动过滤查询,过滤条件完全自定义,支持TextBox,支持DataGridView(弹出查询对话框),支持DevExpress 8.2的TextEdit,Gridview
- scrollView的原理
- Eclipse远程调试应用程序
- VS中创建自定义一个VC工程为基础的开发向导的总结
- SSH 笔记
- 140002 《被淹没和被拯救的》——困惑
- 查询时,保留输入的查询内容,(以及默认选中某个下拉列表
- 在VMware vSphere Client下使用Linux虚拟机安装CentOS6.4系统
- nginx 和 apache 服务器之间的区别及其他替代服务器软件
- 行百里者半九十
- [C++]LeetCode: 55 Decode Ways
- 使用NSIS 打包程序
- SEO教程全攻略对于Nofollow标签了解吗?
- SQL 查询中间表同时满足2钟情况的办法
- 【Android】Handler之线程间通信