首页 > 解决方案 > Nightsbridge 预订日历,提交表单后将输入值发送到重定向页面

问题描述

我正在研究一种简单的代码和平,以便在提交表单后将输入值发送到重定向页面。

但是我完成脚本的技能有点太基础了,我希望下面的脚本重定向如下:

在此生成“签入和签出输入字段”的表单:

<form class="form book-now-form" role="form" id="widget_booking_form" name="widget_booking_form">
    <input id="action" type="hidden" value="2" name="action"> <input id="clone_id" type="hidden" value="1111" name="bbid">
    <!--check in element-->
    <div class="form-group">
       <label for="check-in">Check In</label> <!-- <input type="textfield" class="form-control" id="check-in" placeholder="12.20.2014"> -->
       <input type="text"  class="form-control" id="start-date" name="startdate" placeholder="mm/dd/yyyy">
    </div>
    <!--check out element-->
    <div class="form-group">
       <label for="check-out">Check Out</label> <!-- <input type="textfield" class="form-control" id="check-out" placeholder="12.27.2014"> -->
       <input type="text" class="form-control" id="end-date" name="enddate" placeholder="mm/dd/yyyy" >
    </div>
    <!--submit-->
    <div class="form-group">
       <button name="Submit" href="#" class="btn btn-sm btn-warning">Search</button>
    </div>
</form>

这里用 JS 生成日历和日期:

$( document ).ready(function() {
  $( function() {
    var dateToday = new Date();
    var dates = $("#start-date, #end-date").datepicker({
      defaultDate: "+2d",
      changeMonth: true,
      numberOfMonths: 1,
      minDate: dateToday,
      onSelect: function(selectedDate) {
          var option = this.id == "start-date" ? "minDate" : "maxDate",
          instance = $(this).data("datepicker"),
          date = $.datepicker.parseDate(instance.settings.dateFormat || $.datepicker._defaults.dateFormat, selectedDate, instance.settings);
          dates.not(this).datepicker("option", option, date);
      }
    });
  });
});

但是使用上面的代码,脚本会错误地生成输入值(日期)以及所有输入变量。

所以我现在需要使用以下变量格式将页面重定向到 nightsbrige 的桥( https://www.nightsbridge.co.za/bridge/book )

?action=2&bbid=1111&startdate=2018-05-08&enddate=2018-05-09

并不是?action=2&bbid=1111&startdate=05%2F16%2F2018&enddate=05%2F23%2F2018&Submit=

任何帮助将不胜感激:) 一旦此代码被修复,它将可以免费使用。

标签: javascripthtml

解决方案


推荐阅读