项目中下拉框链接问题

项目中有一个需求:用户开户模板列表的操作按钮中添加设为默认模板按钮,设置完成后,该模板将作为开户时的默认模板,当开户页面加载的时候显示该模板的信息,否则显示请选择模板,下拉框选中哪个则显示哪个模板的信息。

 HTML下拉框链接代码:

<select name="user_templets_id" onchange="javascript:window.open(this.options[this.options.selectedIndex].value,'_self')">
                                <option value="{$url}&user_templets_id=0&defultid=$date">请选择模板</option>
                                <!--{loop $user_templets  $k $v}--><option value="{$url}&user_templets_id={$v['user_templets_id']}&defultid=$date"<!--{if                      $user_templets_id==$v['user_templets_id'] }-->selected="selected" <!--{/if}-->>{$v['templets_name']}</option>
                                <!--{/loop}-->
 </select>

其中$date参数是在选中模板时便于页面刷新

控制器中:

$templets_id=$this->model->get_default_template();//获取默认的开户模板
          if($templets_id>0 && empty($defultid)){
              $user_templets_id = $templets_id;
                 //$default_templets_data = $this->model->get_one_templets_data ( $templets_id );
          }else{
              $user_templets_id = $temp_id ? ( int ) $temp_id : ( int ) $user_templets_id;
          }
          

      // 用户开户显示字段设置
      if ($user_templets_id > 0) {
          $user_templets_data = $this->model->get_one_templets_data ( $user_templets_id );
          $templets_setting = ! empty ( $user_templets_data ['templets_setting'] ) ? explode ( ',', $user_templets_data ['templets_setting'] ) : array ();
          //    print_r($user_templets_data);exit;
      }

原文地址:https://www.cnblogs.com/xlz307/p/3699080.html