javascript - ASK - jquery datepicker - keep selected date in text input -
i made page in html, php , jquery. php script load data date equals date selected in text input using jquery datepicker.
my problem when selected date in datepicker , page load data, text input @ datepicker being blank (no text or date).
so how keep selected date in text input?
<link rel="stylesheet" href="/resources/demos/style.css">
$(function() { $("#datepicker").datepicker({dateformat: 'yy-mm-dd'}); }); $(document).ready(function() { $('#datepicker').change(function() { $('#calendar').submit(); }); });
i need advices fix this. thank help. , want apologize if topic alike another.
thanks help.
here code script
<center> <form id="calendar" action="<?php echo $_server['php_self'];?>" method="get"> <div id="datepicker_start"></div> <input type="hidden" id="datepicker" name="datepicker"> </form> </center> <?php $host = "localhost"; $dbname = "dbname"; $username = "root"; $password = ""; try { $conn = new pdo("mysql:host=$host;dbname=$dbname", $username, $password); $conn->setattribute(pdo::attr_errmode, pdo::errmode_exception); } catch (pdoexception $pe) { die("could not connect database $dbname :" . $pe->getmessage()); } if(isset($_get["datepicker"])){ $datepicker = $_get["datepicker"]; $datepicker2 = date('d-m-y', strtotime($datepicker)); }else{ $datepicker = date('y-m-d'); $datepicker2 = date('d-m-y', strtotime($datepicker)); } $stmt = $conn->prepare("my query"); $stmt->bindparam(':date', $datepicker); $stmt->execute(); $result = $stmt->fetchall(); if (empty($result)) { echo "<center><h3>.:: schedule <i>". $datepicker2 ." ::.</i></h1></center>"; echo "<center><h1>.::no data::.</h1></center>"; }else{ echo "<center><h3>.:: schedule <i>". $datepicker2 ." ::.</i></h1></center>"; echo "<table> <tr> <th>data 1</th> <th>data 2</th> <th>data 3</th> <th>data 4</th> <th>data 5</th> <th>data 6</th> <th>data 7</th> <th>data 8</th> <th>data 9</th> </tr>" ; foreach($result $row) { echo "<tr>"; echo "<td>" . $row['data 1'] . "</td>"; echo "<td>" . $row['data 2'] . "</td>"; echo "<td>" . $row['data 3'] . "</td>"; echo "<td>" . $row['data 4'] . "</td>"; echo "<td>" . $row['data 5'] . "</td>"; echo "<td>" . $row['data 6'] . "</td>"; echo "<td>" . $row['data 7'] . "</td>"; echo "<td>" . $row['data 8'] . "</td>"; echo "<td>" . $row['data 9'] . "</td>"; } echo "</tr>"; echo "</table>"; } ?>
form submit reloads page. should send date server script on form submit , set on input field. or can use ajax
Comments
Post a Comment