简体   繁体   English

试图让jQuery Datepicker起作用

[英]trying to get the jquery Datepicker to function

I can't seem to get this working altho it is all on the website. 我似乎无法在所有网站上都正常工作。 I am not any good at js so that doesn't help either to be honest. 我不太擅长js,因此老实说也无济于事。

so I have basically done exactly the same as what they have on their website but just doesn't seem to function. 因此,我所做的基本上与他们在其网站上所做的相同,但似乎无法正常工作。

Signup open:<br><input type="text" name="reg_start" class="datepicker" value=""/><br>
Signup closed:<br><input type="text" name="reg_end" class="datepicker" value=""/><br>

This is there code what is the same as mine 这里的代码和我的一样

<script language="javascript" src="protoplasm.js"></script>
        <script language="javascript">
            // transform() calls can be chained together
            Protoplasm.use('datepicker')
                .transform('input.datepicker')
                .transform('input.datepicker_es', { 'locale': 'es_AR' });
        </script>

Here are the includes I am doing 这是我正在做的包括

<link rel="stylesheet" href="jquery/datepicker/datepicker.css">
<script src="jquery/protoplasm.js"></script>
<script src="jquery/datepicker/datepicker_src.js"></script>
<script src="jquery/datepicker/datepicker.js"></script>

Here is the website I got the datepicker from 这是我从那里获得日期选择器的网站

http://jongsma.org/software/protoplasm/control/datepicker

I understand that in their code they do not have the extra src includes but I put these in when I have been trying to get it working. 我知道在他们的代码中他们没有额外的src包含,但是当我试图使其工作时,我将它们放入。 I left them in the code as I think I will need to include them but not 100% as once again js isn't my strongest point because I am new to coding and need to get a lot more learning in js. 我将它们留在代码中,因为我认为我需要将它们包括在内,但不必100%包含它们,因为JS并不是我的强项,因为我是编码新手,还需要在JS中学习更多知识。

If anyone could help me out on how to get this working that would be great and I would appreciate any sort of help that you may be able to provide. 如果有人可以帮助我解决这个问题,那将是很棒的,我很感激您可能提供的任何帮助。

Thanks for reading 谢谢阅读

I managed to solve this problem I was having. 我设法解决了这个问题。 What I done was I ended up putting the datepickers into .php file and then included it into my form. 我要做的是最终将datepickers放入.php文件,然后将其包含在我的表单中。 I added the js and css includes into this file as well and everything seems to work. 我也将js和css包含项添加到此文件中,并且一切似乎都正常进行。

below I have included the link to the timepick I used and also my form, php include and the php what is needed to sort the date before sending to the database. 下面,我包括了我使用的时间选择的链接,以及我的表单,php include和php,这些数据在发送到数据库之前需要对日期进行排序。 If anyone finds this answer useful then please hit the +1 button. 如果有人认为此答案有用,请点击+1按钮。

Below is the link to jquery where I got the date and time picker from. 下面是我从中获取日期和时间选择器的jquery链接。 The version I downloaded was 2.1.8 and you should be able to see the download button in right corner and it is a orange button. 我下载的版本是2.1.8,您应该可以在右上角看到下载按钮,它是一个橙色按钮。

http://plugins.jquery.com/datetimepicker/

Below is the .php file. 下面是.php文件。 I called it regend.php all of the jquery and css is included in the link above. 我称它为regend.php,所有的jquery和css都包含在上面的链接中。

<link rel="stylesheet" type="text/css" href="jquery/master/jquery.datetimepicker.css"/>

<input type="text" value="date/time" id="regend" name="reg_end"/>
<script src="jquery/master/jquery.js"></script>
<script src="jquery/master/jquery.datetimepicker.js"></script>


<script>
$('#regend').datetimepicker();
$('#regend').datetimepicker({value:'date/time',step:10});

</script>

Below is the include that I added to my form. 以下是我添加到表单中的内容。 I added this within <form>.......</form> . 我在<form>.......</form> I added it to the location I wished it to be displayed. 我将其添加到希望显示的位置。

Signup close:<?php include("indexmodules/regend.php");?><br><br>

Below is the php code that I used before i sent it to the database to be saved. 以下是在将其发送到数据库进行保存之前使用的php代码。

$reg_end = preg_replace('#[^0-9]#i', '', $_POST ['reg_end']);
$unix_time = strtotime($reg_end);
$date2 = date("Y-m-d H:i:s",$unix_time);

All of the above code should help out any new beginner who is trying to get a date picker working on their website. 上面的所有代码都应该帮助正在尝试使日期选择器在其网站上工作的任何新手。 If I enhance this code I will also post the updated version or version below this. 如果我增强此代码,我还将在此下方发布更新的版本。

Thank you to the guys who commented on my original post and I hope this helps people out in the future. 谢谢那些对我的原始文章发表评论的人,希望这对以后的人们有所帮助。

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

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