Javascript 从一个页面到另一个页面获取php中的jQuery变量
我在我的存档巡更页面上有一个循环,在该循环中,我在选定日期之后的一周输出日期Javascript 从一个页面到另一个页面获取php中的jQuery变量,javascript,php,jquery,wordpress,date,Javascript,Php,Jquery,Wordpress,Date,我在我的存档巡更页面上有一个循环,在该循环中,我在选定日期之后的一周输出日期 <ul class="uol"> <?php $start = strtotime($_GET['date']); $dates = array(); for ($i = 0; $i <= 7; $i++) { $date = date('Y-m-d', strtotime("+$i day", $start)); $date1 =
<ul class="uol">
<?php
$start = strtotime($_GET['date']);
$dates = array();
for ($i = 0; $i <= 7; $i++) {
$date = date('Y-m-d', strtotime("+$i day", $start));
$date1 = $date;
$day = date('D', strtotime($date1));
$date = explode('-', $date);
$dateinput = date('Y-m-d', strtotime("+$i day", $start));
$date = $date[2];
echo '<li class="lia"><input type="hidden" class="getdate" value="'.$dateinput.'"><a href="#tabs-0" class="date">' . $date . ' ' . $day . '</a></li>';
}
?>
<li class="lia" style="background-color:blue"><a style="background- color:blue" href="#tabs-0" class="date tdate"></a></li>
</ul>
这里我有另一个按钮上的循环,如下所示。
凌晨1:00-2:00
<button type="button" style="background-color:blue" id="ttime<?php echo $post->ID?>" class="btn btn-default time-pick tt_time" value=""></button>
for ($i = 0; $i <= 23; $i++) {
am = "";
if ($i <= 12) {
$am = "am";
} else {
$am = "pm";
}
echo '<button type="button" class="btn btn-default">' . $i.':00 ' . $am . ' - ' . ++$i .':00 '. $am . '</button> ';
--$i;
}
在jquery中,您可以使用localStorage
localStorage.setItem('t_time','Your setTime' ); //set your value
并且得到
localStorage.getItem('t_time'); //Get your value
使用jquery的$.post()
如下所示
var ttime = jQuery('#time<?php echo $post->ID?>').html();
$.post('php_file_name.php',{'ttime':ttime},function(data,status){
});
var ttime = jQuery('#time<?php echo $post->ID?>').html();
$.post('php_file_name.php',{'ttime':ttime},function(data,status){
});
$time = $_POST['ttime'];//get ttime send from jquery
//echo $time