doushan9415 2015-09-27 10:57
浏览 46

PHP - Codeigniter并非所有表单元素都通过post方法发送到控制器

I have a form like the code below, when the submit button is clicked, not all elements of the form being sent to Codeigniter's controller, especially txtStartLocation and txtEndLocation. I clearly defined the names for both elements. Here what I got when var_dump the post element

array(8) { 
["txtStartDate"]=> string(10) "2015-09-29" 
["txtEndDate"]=> string(10) "2015-09-30" 
["txtStartTime"]=> string(4) "8:45" 
["txtEndTime"]=> string(5) "14:45" 
["txtStartLocation_Coordinates"]=> string(32) "(36.106965, -112.11299700000001)" 
["txtEndLocation_Coordinates"]=> string(23) "(37.559152, 126.983967)"
["txtTotalDetail"]=> string(1) "0" 
["txtNoOfDays"]=> string(1) "2" }`

Form View

 <form name="frm_RRequest" id="frm_RRequest" action="<?php echo site_url('user/add_recommendation_request/'); ?>" method="post">                      
                    <tbody>
                      <tr>
                        <td class="col-left">Date</td>
                        <td class="col-middle"><input class="datepicker" type="text" name="txtStartDate" id="txtStartDate" class="datepicker" placeholder="Click to select a start date.."></td>
                        <td class="col-middle"><input class="datepicker" type="text" name="txtEndDate" id="txtEndDate" class="datepicker" placeholder="Click to select a end date.."></td>
                        <td class="col-right"><div class="error" id="error_date">&nbsp;</div></td>
                      </tr>
                      <tr>
                        <td class="col-left">Travel time</td>
                        <td class="col-middle"><input type="text" class="ptTimeSelect input" name="txtStartTime" id="txtStartTime" placeholder="Click to select start time.." data-default-time="false"></td>
                        <td class="col-middle"><input type="text" class="ptTimeSelect input" name="txtEndTime" id="txtEndTime" placeholder="Click to select end time.." data-default-time="false"></td>
                        <td class="col-right"><div class="error" id="error_time">&nbsp;</div></td>
                      </tr>
                      <tr>
                        <td class="col-left">Location</td>
                        <td class="col-middle-2"><input type="text" class="inputWithImge" name="txtStartLocation" id="txtStartLocation" onmouseover="display_text(this)" placeholder="Click the icon to select a start point"/><img src="<?php echo base_url('assets/images/search_icon.png'); ?>" class="location-icon" title="Click to show map" name="location-icon_start" value="StartLocation"/></td>
                        <td class="col-middle-2"><input type="text" class="inputWithImge" name="txtEndLocation" id="txtEndLocation" onmouseover="display_text(this)" placeholder="Click the icon to select a end point"/><img src="<?php echo base_url('assets/images/search_icon.png'); ?>" class="location-icon" title="Click to show map" name="location-icon_end" value="EndLocation" /></td>
                        <td class="col-right"><div class="error" id="error_location">&nbsp;</div></td>
                      </tr>
                    </tbody>
                  </table>
                </div>
                <input type="hidden" name="txtStartLocation_Coordinates" id="txtStartLocation_Coordinates">
                <input type="hidden" name="txtEndLocation_Coordinates" id="txtEndLocation_Coordinates">
                <div><input type="button" class="button" id="btnGo" name="btnGo" value="Input detail" />&nbsp; <span> << click this button if the travel time and location(s) are different for each day</span></div>
                <div id="detail"> 

                </div>
                <input type="hidden" name="txtTotalDetail" id="txtTotalDetail">
                <input type="hidden" name="txtNoOfDays" id="txtNoOfDays">
                <div>&nbsp;</div>
                <div><input type="button" id="btn_SaveDetail" name="btn_SaveDetail" class="button" value="Save" /></div>
</form>
  • 写回答

1条回答 默认 最新

  • dongye1942 2015-09-28 06:15
    关注

    Try to use open/close form like this:

    <?php echo form_open("controller/function"); ?>
    
    <?php echo form_close(); ?>
    

    then change

    <input type="button" id="btn_SaveDetail" name="btn_SaveDetail" class="button" value="Save" />
    

    into

    <input type="submit" id="btn_SaveDetail" name="btn_SaveDetail" class="button" value="Save" />
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题