简体   繁体   English

日期选择器PhP / JQuery

[英]Date selector PhP/JQuery

I looked for answers, but I am a newbie to PhP/JQuery so the answers I found confused me further. 我在寻找答案,但是我是PhP / JQuery的新手,所以我发现的答案进一步使我感到困惑。

I have a wordpress website that contains a form with a date selector field I am trying to determine when the user selects a new date and save that date to a variable to be used somwhere else 我有一个wordpress网站,其中包含带有日期选择器字段的表单,我试图确定用户何时选择新日期并将该日期保存到要在其他地方使用的变量中

On change doesn't work cause of the lack of focus etc... 变革无济于事,原因是缺乏专注力等。

I tried select, and that didn't do anything 我尝试选择,但没有做任何事情

In the process of trying to figur eout what I am doing wrong, I simplified the code where once it is selected it gives me a message box! 在尝试找出我做错了什么的过程中,我简化了代码,选择该代码后会给我一个消息框! the code is below: Any help is greatly appreciated! 代码如下:非常感谢您的帮助!

$JScript ="<script>
jQuery('#wdform_2_element13').on('select',function() 
        {
            alert('Here');

        }
</script>"

You can stop the process when your saving all your data from the form, and call a new function to save or do whatever you want to that variable. 当您保存表单中的所有数据时,可以停止该过程,并调用一个新函数来保存或对该变量执行任何操作。

You can do that by pointing your form submissions to a specific file in the wp-admin directory called admin-post.php 您可以通过将表单提交指向wp-admin目录中名为admin-post.php的特定文件来admin-post.php

Take a look to this tutorial and I'm sure you will learn some basic knowledge about WP code and also the answer to your question: 看一下本教程,我相信您会学到一些有关WP代码的基本知识,以及您问题的答案:

https://www.sitepoint.com/handling-post-requests-the-wordpress-way/ https://www.sitepoint.com/handling-post-requests-the-wordpress-way/

It turns out the reason is cause the field was a date picker that was already defined through the form maker i was using. 事实证明,原因是该字段是通过我使用的表格制造商已经定义的日期选择器。 So what I did was create a date picker using Jquery, then use the "onSelect:function" and that was it 所以我所做的就是使用Jquery创建日期选择器,然后使用“ onSelect:function”,仅此而已

Thanks for the help 谢谢您的帮助

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

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