doujiang6944 2017-10-24 10:36
浏览 29
已采纳

在codeigniter中保持页面重定向中的下拉值

I have two input fields and one dropdown in a form. When I put data to these three, I click the search button. After that I come to another page. But after the redirect to the previous page how to keep previous selected value in dropdown and two input fields.

<input type="text" id=first>
<input type="text" id=second>
<select id=oid>
     <option></option>
</select>

<div class="col-md-4">
<button type="button" onclick="location.href = '<?php echo base_url(); ?>/index.php/Orders/'" class="btn btn-primary btn-md">Back </button>
</div>

any help thanks in advance

  • 写回答

1条回答 默认 最新

  • dqoys62082 2017-10-24 10:48
    关注

    You can use GET method to achieve this result

    <form method="get" action="<?php echo base_url(); ?>/index.php/Orders/'">
    <input type="text" id=first name="first">
    <input type="text" id=second name="second">
    <select id=oid>
         <option></option>
    </select>
    
    <div class="col-md-4">
    <button type="submit" class="btn btn-primary btn-md">Back </button>
    </div>
    

    Your URL will be like this

    http://somedomain.com/index.php/Orders/?first=john&second=Doe
    

    Edit

    But when you want to keep the post values for sometime in the application even you moving around to other pages, you may think of session in PHP

    In Codeignite way, it will be as follows

    $this->session->set_userdata('first', $_POST['first']);
    

    To get this value

    $this->session->userdata('first');
    

    Sample input element in your case

    $first = $this->session->userdata('first');
    <input type="text" id=first name="first" value="<?php echo $first?>">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 linux驱动,linux应用,多线程
  • ¥20 我要一个分身加定位两个功能的安卓app
  • ¥15 基于FOC驱动器,如何实现卡丁车下坡无阻力的遛坡的效果
  • ¥15 IAR程序莫名变量多重定义
  • ¥15 (标签-UDP|关键词-client)
  • ¥15 关于库卡officelite无法与虚拟机通讯的问题
  • ¥15 目标检测项目无法读取视频
  • ¥15 GEO datasets中基因芯片数据仅仅提供了normalized signal如何进行差异分析
  • ¥100 求采集电商背景音乐的方法
  • ¥15 数学建模竞赛求指导帮助