dongtu0088 2014-02-06 22:43
浏览 21


As the title says, how can i test/show my jQuery variable in php? I have created a datepicker and on the click of a specific date, that date needs to be stored into a variable so i can use it later on (like for example to show your date of birth).

The code of the datepicker and the Onselect is:

        onSelect: function(dateText, inst) {
        showOn: "button",
        buttonImage: "/debasis/hoofdstuk03/img/calendar.png",
        buttonText: "Open de kalender",
        buttonImageOnly: true,
        inline: true,  
        showOtherMonths: true,  
        dayNamesMin: ['Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za','Zo'],  
        monthNames: ['Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni',
            'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'],


The HTML to show the datepicker is:

<div type="text" id="datepicker"></div>
   <form method=post>
       <input type='text' id='thedate' name='thedate' />

If im right, but correct me if i am wrong, when i click a date on the calendar, that date is being POST and the Jquery variable 'thedate' will be set in $_POST['thedate'] is this correct?

However to be sure i got the chosen date in my $_POST (so i can use this variable to store it in my databse) i wanted to test it with an echo. So in the same file i created this to test it:

<?php print_r($_POST); ?>

Though this little line doesnt return anything? Anyone knows how i can test/show 'thedate' variable (the chosen date)? So i know the chosen date is stored in a variable. I would like to get it returned in a PHP variable so i can store it in my databse.. Though if there are other ways to do it i am open for those solutions as well. :)

  • 写回答

2条回答 默认 最新

  • dongmaonao0505 2014-02-06 22:48

    nope; it doesn't work like that. It's not enough to just change input value. You need to actually submit the form - which means comunicating with php which is BACK-END, to be able to show it using PHP.

    the easiest way would be to submit the form in onSelect method:



                onSelect: function(dateText, inst) {

    and then print it out usign PHP:

    <?php print_r($_POST); ?>
    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥20 找驱动QTR2774-SU-IBM版本驱动
  • ¥15 NeRF的代码复现以及人工智能入门
  • ¥15 centos如何做一个可以让ikuai连接的openvpn
  • ¥15 Protege 中的Entities下面的界面删除了如何复原
  • ¥15 scrapy爬虫求帮
  • ¥15 imageEnView绘图问题
  • ¥15 关于#python#的问题:您好可以加您一下联系方式吗,在复现的时候确实有点问题难以解决
  • ¥15 联想电脑重装系统时无法发现硬盘
  • ¥15 MATLAB与UR10e实体机械臂建立通讯
  • ¥15 c++题需要快一点不用opencv