dousui3124 2014-09-30 02:52
浏览 28

尝试在下拉表单中将name作为参数传递

I have a form where I am dynamically passing an id already of an array of populated events. I need to now pass a name so the name can later be grabbed to store in the database.

This is not working passing the name through $attributes. Because when I inspect the div element where the value appears after selected, it just shows the id of the event from the elements table.

 <?php
            if($user_events){
                //print_r($user_events);
            ?>
            <div class="row">
              <div class="col-md-12">
                <h3>Add Event To Location</h3>
                <div class="row">

                  <div class="row">
                  <div class="row">

                    <div id="myselect" class="col-md-12">
                        <p></p>

                      <div class="form-group col-xs-5 col-lg-3">
                      <?php 
                        //$user_events = '';
                        //print_r($user_events);
                        $ar=array();
                        foreach($user_events as $events) {
                            $ar[$events['id']] = $events['title'];
                            }
                      //endforeach;
                        ?>

                        <?php
                        $attributes = 'input type = “hidden” name="posted_event[]"';
                         //$attributes='';
                         echo form_dropdown('myselect', $ar, '',$attributes);    

                        ?> 

                    </div>
                  </div>
                </div>

              </div>
              </div>
              <?php    
              }
              ?>
              <button id="grab1" type="button" class="btn btn-default">Clear</button>
                      <hr/>
            </div>

Basically when I inspect the element I need to see this

<input type = “hidden” name = “posted_event[]">

Updated:

$attributes = '<input type = "hidden" name="posted_event[]">';
  • 写回答

3条回答 默认 最新

  • dongxieli3839 2014-09-30 03:18
    关注

    You are using form_dropdown which is for a drop down, you need to use form_input() if you want to produce what you want.

        $data = array(
                      'type'        => 'hidden',
                      'name'          => 'postedevent[]',
                    );
    
    echo form_input($data);
    
    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能