简体   繁体   English

将数据从一个日期选择器传递到另一个

[英]Pass data from one date picker to another

I have this situation: 我有这种情况:

2 files (contact.html and booking.php) 2个文件(contact.html和booking.php)
On my contact.html I have the following code: 在我的contact.html上,我有以下代码:

<form action="booking.php" method="POST" role="form" class="formular">
    <h3>Online booking!</h3>
    <br />
    <div class="control-group">
        <div class="controls">
            <div class="input-group">
                <input type="text" id="dateFrom" name="dateFrom" class="form-control" placeholder="Check in" style="width: 258px;"/>
            </div>
        </div>
    </div>
    <div class="control-group">
        <div class="controls">
            <div class="input-group">
                <input type="text" id="dateToInput" name="dateToInput" class="form-control" placeholder="Check out" style="width: 258px;"/>
            </div>
        </div>
    </div>
</form>

On my booking.php file I have the following code: 在我的booking.php文件中,我具有以下代码:

<form>
    <div class="booking">
        <form name="" action=" " method="post">
        <h1>BOOKING</h1>
            <div class="bookingDate">
                <p>Check in:</p>
                <div id="dateFrom">
                </div>
            </div>
    </div>
    <div class="bookingDate">
        <p>Check out:</p>
        <div id="dateTo">
        </div>
    </div>
    <input type="hidden" name="dateFrom" id="dateFromInput" value= $_POST["dateFrom"] />
    <input type="hidden" name="dateTo" id="dateToInput" value=$_POST["dateTo"]/>
</form>

So, I have two calendars on my contact.html page and two calendars on booking.php. 因此,我的contact.html页面上有两个日历,booking.php上有两个日历。 I want that when I choose 2 dates (on my contact.html) form, those exact dates to be passed to the other two calendars that I have on booking.php Could anyone please help me? 我希望当我选择2个日期(在contact.html上)表格时,这些确切的日期将传递到我在booking.php上拥有的其他两个日历中,有人可以帮助我吗? I have searched a lot and I can't find an answer. 我已经搜索了很多,但找不到答案。

Modify the code to following in value section. 修改代码以遵循“值”部分中的内容。 Similary for other field as well. 其他领域也是如此。

<input type="hidden" name="dateFrom" id="dateFromInput" value= "<?php echo $_POST["dateFrom"] ?>" />

Contact has name="dateToInput" yet booking is looking for dateTo 联系人name="dateToInput"但预订正在寻找dateTo
Fix one: correct the name of the input in contact 解决方法一:更正联系人中输入的名称

<input type="text" id="dateToInput" name="dateTo" class="form-

Fix two: You have no PHP tags in your booking code, without them $_POST is not available, nor are those values being printed. 修正二:您的预订代码中没有PHP标记,没有它们,$ _ POST不可用,也不会打印这些值。

<input type="hidden" name="dateFrom" 
id="dateFromInput" value="<?php echo $_POST["dateFrom"];?>">

<input type="hidden" name="dateTo" 
id="dateToInput" value="<?php echo $_POST["dateTo"]; ">

Note I also wrapped the values with quotes 注意我也用引号将values包装起来

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM