簡體   English   中英

PHP-Codeigniter並非所有表單元素都通過post方法發送到控制器

[英]PHP - Codeigniter not all form elements being sent to controller by post method

我有一個類似於以下代碼的表單,當單擊“提交”按鈕時,並非表單的所有元素都被發送到Codeigniter的控制器,尤其是txtStartLocationtxtEndLocation 我明確定義了這兩個元素的名稱。 這是當var_dump post元素時我得到的

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 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>

嘗試使用打開/關閉表單,如下所示:

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

<?php echo form_close(); ?>

然后改變

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

進入

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM