形成执行行动和逾越的价值观

Form to perform action and passover the values

本文关键字:价值观 执行      更新时间:2023-09-26

嗨,我基本上有一个表单,它有两个文本框将数据发送回谷歌电子表格,因为我已经将我的表单附加到谷歌表单,如果你知道如何做到这一点,那就好了,如果不是你可以看看这里http://www.morningcopy.com.au/tutorials/how-to-style-google-forms/lets调用它们,

<form action="LINK TO GOOGLE SPREAD SHEET LINK" method="post">
<input type="text" id="tb1" name="tb1"/>
<input type="text" id="tb2" name="tb2"/>
<input type="submit" value="submit"/>
</form>

所以我的问题是一旦数据提交,我想要得到textbox2。值传递到下一页,我们将其命名为page2.html,因此前面的tb2。Value传递给page2.html textbox1.value。我也知道如何导航到下一页,这样就不是问题了,问题是如何从tb2获得值,并同时提交表单。我一直在努力完成这件事。

<form action="LINK TO GOOGLE SPREAD SHEET LINK" method="post">
<input type="text" id="tb1" name="tb1"/>
<input type="text" id="tb2" name="tb2"/>
<input type="submit" value="submit"/>

</form>
SO I HAVE MODIFIED TO LOOK AS BELOW 
For the first page is this its name is Testhtml.html

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>TEsthtml.html</title>
    </head>
    <body>
    <iframe name="response_iframe" id="hidden_iframe" style="display:none;" onload="if(submitted){window.location='simple.html';}"></iframe>
    <form action="https://docs.google.com/spreadsheet/formResponse?formkey=dDN5RE9ueU9HRGdQYzlJYWhrRUY1UEE6MQ&ifq" target="response_iframe" onSubmit="submitted=true;" method="POST">
    <label  for="entry_0">Type ur name</label>
    <input type="text" name="entry.0.single" value=""  id="entry_0">
    <br> 
    <label  for="entry_1">ur pets name
    </label>
    <label  for="entry_1">type something</label>
    <input type="text" name="entry.1.single" value=""  id="entry_1">
    <br>
    <input type="submit" name="submit" value="Submit">
    <script type="text/javascript">
    $(document).ready(function () {
        $('commentForm').submit(function () {
            var tb2_val = $('input#entry_1', $(this)).val();
            // do something with tb2_val
    localStorage.setItem('hpnumber', tb2_val);
            // return false; // uncommenting this will prevent the submit action
        });
    });
    </script>
    </form>
    </body>
    </html>

第二页是这个它的名字是simple.html

 <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Simple HTML</title>
    <script type="text/javascript">
    $(document).ready(function () {
        var thevalue = localStorage.getItem("hpnumber")
        $('form').find('input#tb1').val(thevalue);
    });
    </script>
    </head>
    <body>
    <script type="text/javascript">
    $(document).ready(function () {
        var thevalue = localStorage.getItem("hpnumber")
        $('form').find('input#tb1').val(thevalue);
    });
    </script>
    <input id="tb1" name="tb1" type="text"/>

    </body>
    </html>

,但仍然不工作,而数据能够提交和第二页的simple.html是打开文本框值设置为什么都只是空白..请帮助这个tks。顺便说一句,当你按下提交按钮时,你可以看到数据在谷歌电子表格中被更新,电子表格在这里被公开了。https://docs.google.com/spreadsheet/ccc?key=0AqUqEITRLZjYdDN5RE9ueU9HRGdQYzlJYWhrRUY1UEE

在提交时使用

获取表单值
$(document).ready(function () {
    $('form').submit(function () {
        var tb2_val = $('input#tb2', $(this)).val();
        // do something with tb2_val
        // return false; // uncommenting this will prevent the submit action
    });
});

至于在页面之间传递值,你必须决定如何处理它(cookie, url参数,存储到db/从db检索,html5本地存储等)。确定方法后,获取值并执行

$(document).ready(function () {
    var thevalue = ///
    $('form').find('input#tb1').val(thevalue);
});