Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/368.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何从textbox获取用户输入,以便在倒计时脚本中使用它?_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何从textbox获取用户输入,以便在倒计时脚本中使用它?

Javascript 如何从textbox获取用户输入,以便在倒计时脚本中使用它?,javascript,jquery,html,Javascript,Jquery,Html,嗨,我有一个倒计时系统,我想知道如何将它作为变量,这是脚本:in secondpage.html <script> var message = new Array(); message[0] = "status: just started"; message[10] = "status: drinking a coffe"; message[20] = "status: just finished setting up the database";

嗨,我有一个倒计时系统,我想知道如何将它作为变量,这是脚本:in secondpage.html

<script>

    var message = new Array();
    message[0] = "status: just started";
    message[10] = "status: drinking a coffe";
    message[20] = "status: just finished setting up the database";
    message[30] = "status: brainstorming about the template";
    message[50] = "status: choosing the color scheme";
    message[80] = "status: thinking about the future";
    message[90] = "status: nearly done";
    message[100] = "status: finished";

    jQuery(document).ready(function () {


        function callback() {
            alert("finish");
        }
        $("#flipit").coffeetime({
            /* COUNTDOWN SETTINGS */
            message: message, // the message array with the array keys as percent values
            startYear: 2013,
            startMonth: 8,
            startDay: 1,
            endYear: 2015,
            endMonth: 0,
            endDay: 0,
            soundControlCssClass: 'icon sound margin-top-20  body-google-font',
            messageBoxId: "percent-message",
            callbackFinish: callback,
        });


        $(".flip-title-subheading").html("was created in: " + new Date() + " and we`ll finish after: " + window.endDate);

    });
    jQuery(document).ready(function () {
        setTimeout(function () {
            $(".flip-container").animate({
                "height": 105 + "px"
            }, 1000, "swing");
        }, 1000);
    });
</script>

var message=新数组();
消息[0]=“状态:刚开始”;
消息[10]=“状态:喝咖啡”;
消息[20]=“状态:刚刚完成数据库设置”;
消息[30]=“状态:关于模板的头脑风暴”;
消息[50]=“状态:选择配色方案”;
信息[80]=“状态:思考未来”;
消息[90]=“状态:接近完成”;
消息[100]=“状态:已完成”;
jQuery(文档).ready(函数(){
函数回调(){
警报(“完成”);
}
美元(“#flipit”)。咖啡时间({
/*倒计时设置*/
message:message,//数组键作为百分比值的消息数组
起始日期:2013年,
开始月份:8,
开始日期:1,,
年末:2015年,
月末:0,
完日期:0,
soundControlCssClass:“图标声音边距-top-20 body谷歌字体”,
messageBoxId:“消息百分比”,
callbackFinish:callback,
});
$(“.flip title subheading”).html(“是在:“+new Date()+”中创建的,我们将在:“+window.endDate”之后完成);
});
jQuery(文档).ready(函数(){
setTimeout(函数(){
$(“.flip container”).animate({
“高度”:105+“像素”
},1000,“摇摆”);
}, 1000);
});
我用“new date()”解决了开始年份的问题,但问题是结束日期, 我想让endYer、endMonth和endDay成为用户可以输入的变量, 输入页面pageone.html:

Year: <input type="text" name="Year" id="Year" size="4"><br />
    Month: <input type="text" name="Month" id="Month" size="2"><br />
    Day: <input type="text" name="Day" id="Year" size="2"><br />
年份:
月份:
日期:
我希望将这些输入传输到secondpage.html,以便在倒计时脚本中使用它


请告诉我怎么做。

我认为您需要的是一些服务器端代码,它将接收pageone.html上表单提交的数据,并在您提交时将其传递到secondpage.html,这需要类似PHP(或您选择的另一种服务器端语言)的东西

这意味着pageone.html的外观如下:


年份:
月份:
日期:
…和secondpage.html将成为secondpage.php,并将类似于以下内容:



var message=新数组();
消息[0]=“状态:刚开始”;
消息[10]=“状态:喝咖啡”;
消息[20]=“状态:刚刚完成数据库设置”;
消息[30]=“状态:关于模板的头脑风暴”;
消息[50]=“状态:选择配色方案”;
信息[80]=“状态:思考未来”;
消息[90]=“状态:接近完成”;
消息[100]=“状态:已完成”;
jQuery(文档).ready(函数(){
函数回调(){
警报(“完成”);
}
美元(“#flipit”)。咖啡时间({
/*倒计时设置*/
message:message,//数组键作为百分比值的消息数组
起始日期:2013年,
开始月份:8,
开始日期:1,,
年底:,
月底:,
(完):,
soundControlCssClass:“图标声音边距-top-20 body谷歌字体”,
messageBoxId:“消息百分比”,
callbackFinish:callback,
});
$(“.flip title subheading”).html(“是在:“+new Date()+”中创建的,我们将在:“+window.endDate”之后完成);
});
jQuery(文档).ready(函数(){
setTimeout(函数(){
$(“.flip container”).animate({
“高度”:105+“像素”
},1000,“摇摆”);
}, 1000);
});
请注意倒计时设置部分中的php标记,它们通过secondpage.php顶部php中设置为变量的值


希望这有帮助,伙计,非常感谢你的重播,我按照你说的做了,但是id不起作用,我想我把
放错了位置,我应该把这些代码放在第二页的顶部。如果它仍然不起作用,那么可能是因为你的服务器环境无法处理php。尝试将其放在secondpage.php的顶部,如果您没有看到有关php安装的大量信息,那么它不是为php设置的,因此您可能必须首先将其整理出来。或者,我错过了一些非常明显的东西,我想检查一下,我没有做任何愚蠢的事情,但意识到我没有secondpage.php中的任何HTML,因此显然什么也看不到,但是我在pageone.HTML中输入的值被提取并输入脚本,因此假设您的服务器可以处理php,那我的建议就行了。非常感谢兄弟,你对我做得很好,光说几句话是不够的。
<?php
$end_year = (int) $_POST['Year'];
$end_month = (int) $_POST['Month'];
$end_day = (int) $_POST['Day'];
?>