简体   繁体   English

我如何从文本框中获取用户输入以在倒计时脚本中使用它?

[英]How can i get user input from textbox to use it in my countdown script?

Hi i have a countdown system i want to know how to make it as a variable, this is the script: in secondpage.html 嗨,我有一个倒计时系统,我想知道如何将其设置为变量,这是脚本: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>

i had solved the start year by putting "new date()", but the problem is with the end date, i want endYer, endMonth and endDay to be a variables that the user can input them, the input page pageone.html: 我已经通过放置“ 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 />

i want these input to be transfer to secondpage.html to use it in the countdown script 我希望将这些输入传递到secondpage.html以在倒计时脚本中使用它

please tell me how. 请告诉我如何。

I think what you're after is some server side code that will take the data submitted by a form on pageone.html and pass it through to secondpage.html when you submit it, which would require something like PHP (or another server side language of your choosing). 我认为您所需要的是一些服务器端代码,这些代码将采用pageone.html上的表单提交的数据,并在提交时将其传递给secondpage.html,这将需要PHP(或其他服务器端语言)您的选择)。

This would mean pageone.html would look something like this: 这意味着pageone.html将如下所示:

<form method="post" action="secondpage.php">
    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 />
    <input type="submit" value="submit" />
</form>

...and secondpage.html would become secondpage.php and would look something like this: ...和secondpage.html将变成secondpage.php,看起来像这样:

<?php
$end_year = (int) $_POST['Year'];
$end_month = (int) $_POST['Month'];
$end_day = (int) $_POST['Day'];
?>
<script type="text/javascript">

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: <?php echo $end_year; ?>,
        endMonth: <?php echo $end_month; ?>,
        endDay: <?php echo $end_day; ?>,
        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>

Note the php tags in the countdown settings section passing through the values set as variables in the PHP at the top of secondpage.php 请注意,在“倒数计时设置”部分中的php标签会通过secondpage.php顶部的PHP中设置为变量的值。

Hope that helps 希望能有所帮助

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

相关问题 如何在AngularJS的文本框输入更改中执行脚本? - How can I get my script to execute on a textbox input change in AngularJS? 如何设置倒计时脚本的当前日期? - How can i set the current date for my countdown script? 如何在提交脚本中使用表单输入值? - How can I use form input values in my submission script? 如何基于我在HTML表单上的用户输入来更新PHP脚本 - How can I update my PHP script based on my user input on HTML form 如何获取Java脚本中的用户输入并在页面上显示此输入? - How can I get user input in java script and display this input on page? 如何使用Java Script从输入区域获取用户输入并分配给变量? - How do I get user input from input area with Java Script and assign to a variable? 我怎样才能只获得在我的文本框中输入的小时数,并在 rateperhour 中与 keyup 输入相乘,然后在我的总数中显示答案? - How can I get Hours only that was inputted on my textbox and multiply with keyup input in rateperhour then display the answer in my total? 如何通过倒计时获得 href URL? - How can I get href URL with countdown? 如何从我的选择选项中获取要输入的数据 - How can I get data to input from my select option Jquery可以直接从表单中获取表单输入,还是必须在脚本中使用SET按钮? - Can Jquery take the form input straight from the form, or do I have to use a SET button in my script?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM