douliao2493 2015-07-17 09:29
浏览 17
已采纳

set_select()在codeigniter框架中不起作用

I want the select box show the same value before the from submit after the redirection in this code $cat value come to the session i am not using validation rule for select box i want only the select box not change after the redirection Select Leave Category... leave_category_id ?>"

                <?php echo set_select('leave_category_id', $cat, true); ?>> <?php echo $v_category->category ?>  </option>

    <?php endforeach;
    ?>
</select>
  • 写回答

2条回答 默认 最新

  • duanjiwang2927 2015-07-17 09:44
    关注

    Try

    <select name="leave_category_id" class="form-control" onchange="check_leave_category(this.value)" required  >
        <option>Select Leave Category...</option>
        <?php foreach ($all_leave_category as $v_category) :
    
            // Using short tag
            //$v_category->leave_category_id == $cat ? $selected = 'selected' : $selected = '';
    
            // without using short tag
            if($v_category->leave_category_id == $cat) $selected = 'selected'; else $selected = '';
            ?>
            <option value="<?php echo $v_category->leave_category_id ?>" <?php echo $selected?> > <?php echo $v_category->category ?>  </option>
    
        <?php endforeach;
        ?>
    </select>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?