代码:
<script>
$(document).ready(function(){
$("#start-date-1").datepicker();
$("#end-date-1").datepicker();
$("#book_now").click(function(e){
e.preventDefault();
locations = $("#location").val();
start_date = $("#start-date-1").val();
end_date = $("#end-date-1").val();
guests = $("#guests").val();
if(locations=='' && start_date!='' && end_date!='' && guests!='')
{
$("#location").addClass("red_border");
}
else if(locations!='' && start_date!='' && end_date!='' && guests!='')
{
window.location.href="{{URL::to('s?location="+locations+"')}}";
}
});
});
</script>
在这段代码中,我只是获取值,locations, start_date, end_date, guests并且所有变量值都显示在警报中,但是当我单击book_now它时会重定向我,window.location.href但locations查询字符串中的值未正确显示。
它是http://localhost/luxvacationrentalhomes.com/s?location="+locations+"而且应该是http://localhost/luxvacationrentalhomes.com/s?location=2。
我怎样才能解决这个问题?
梦里花落0921
慕森卡