简体   繁体   中英

Pass data from one date picker to another

I have this situation:

2 files (contact.html and booking.php)
On my contact.html I have the following code:

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

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

<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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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