我有九个文本框包装在一个表单中但是当发布到codeigniter控制器时,有两个特定的文本框没有值,但它们实际上有。 有没有人遇到过这个问题?究竟是什么错?
表格
<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"> </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"> </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"> </div></td>
</tr>
<input type="hidden" name="txtStartLocation_Coordinates" id="txtStartLocation_Coordinates">
<input type="hidden" name="txtEndLocation_Coordinates" id="txtEndLocation_Coordinates">
</tbody>
</table>
</div>
<div><input type="button" class="button" id="btnGo" name="btnGo" value="Input detail" /> <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> </div>
<div><input type="button" id="btn_SaveDetail" name="btn_SaveDetail" class="button" value="Save" /></div>
</form>
<script>
function display_text(obj){
var value = obj.value;
obj.title = value;
}
</script>
控制器:
$total_detail = $this->input->post("txtTotalDetail");
$noOfDays = $this->input->post("txtNoOfDays");
$userid = $this->session->userdata('id');
$start_date = $this->input->post("txtStartDate");
$end_date = $this->input->post("txtEndDate");
$start_time = $this->input->post("txtStartTime");
$end_time = $this->input->post("txtEndTime");
$start_location = $this->input->post("txtStartLocation");
$end_location = $this->input->post("txtEndLocation");
$start_location_coor = $this->input->post("txtStartLocation_Coordinates");
$end_location_coor = $this->input->post("txtEndLocation_Coordinates");
这两个文本框没有值:
$start_location = $this->input->post("txtStartLocation");
$end_location = $this->input->post("txtEndLocation");
答案 0 :(得分:0)
您可能忘记在这些特定字段上使用$this->form_validation->set_rules()
。
答案 1 :(得分:0)
将值放在输入标记中,如
<input type="hidden" name="txtStartLocation_Coordinates" value ="<?php echo $this->input->post('txtStartLocation_Coordinates');?>" id="txtStartLocation_Coordinates">
<input type="hidden" name="txtEndLocation_Coordinates" value ="<?php echo $this->input->post('txtEndLocation_Coordinates');?>" id="txtEndLocation_Coordinates">
<script>
$(function(){
$('#txtStartLocation_Coordinates').val("your value");
$('#txtEndLocation_Coordinates').val("your value");
});
</script>