Html表单不在GET上向URL添加参数

时间:2014-02-22 18:45:07

标签: jquery html css

我正在使用groundworkcss并创建了一个简单的html表单。但是当我提交表单时,生成的URL只是“file:// C://MyFiles//results.html?”

字段txtName的值未添加到网址中。 最小的非工作代码如下所示。

<html class="no-js"><!--<![endif]-->
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1">
    <title>Test &hearts; Test Information</title>
    <!-- Modernizr -->
    <script src="../js/libs/modernizr-2.6.2.min.js"></script>
    <!-- jQuery-->
    <script type="text/javascript" src="../js/libs/jquery-1.10.2.min.js"></script>
    <!-- framework css --><!--[if gt IE 9]><!-->
    <link type="text/css" rel="stylesheet" href="../css/groundwork.css"><!--<![endif]--><!--[if lte IE 9]>
    <link type="text/css" rel="stylesheet" href="../css/groundwork-core.css">
    <link type="text/css" rel="stylesheet" href="../css/groundwork-type.css">
    <link type="text/css" rel="stylesheet" href="../css/groundwork-ui.css">
    <link type="text/css" rel="stylesheet" href="../css/groundwork-anim.css">
    <link type="text/css" rel="stylesheet" href="../css/groundwork-ie.css"><![endif]-->
    <style type="text/css">
      .logo {
        position: relative;
        top: -0.5em;
      }
      .logo a, .logo a:visited {
        text-decoration: none;
        color: #2B2B2D;
      }
      .logo img {
        height: 2em;
        position: relative;
        top: 0.55em;
        margin-right: 0.3em;
      }

    </style>
    <!-- snippet (syntax highlighting for code examples)-->
    <script type="text/javascript" src="../js/demo/jquery.snippet.min.js"></script>
    <link type="text/css" rel="stylesheet" href="../css/demo/jquery.snippet.css"><script type="text/javascript">
(function() {

  $(document).ready(function() {
    $('pre[data-lang="html"]').snippet("html", {
      style: "groundwork",
      clipboard: "../js/demo/ZeroClipboard.swf"
    });
    $('pre[data-lang="css"]').snippet("css", {
      style: "groundwork",
      clipboard: "../js/demo/ZeroClipboard.swf"
    });
    $('pre[data-lang="sass"]').snippet("sass", {
      style: "groundwork",
      clipboard: "../js/demo/ZeroClipboard.swf"
    });
    return $('pre[data-lang="js"]').snippet("javascript", {
      style: "groundwork",
      clipboard: "../js/demo/ZeroClipboard.swf"
    });
  });

}).call(this);
</script>
  </head>
  <body>

    <form action="results.html" method="get">
                        <fieldset>




                                    <label for="name">Name </label>
                                    <input id="txtNane" type="text" placeholder = "Enter your Name">

                                    <br>
                                    <hr>
                                    <button id = "btnSubmit" type="submit"> Submit </button>

                                </fieldset></form>
    <!-- javascript-->
    <script type="text/javascript" src="../js/groundwork.all.js"></script>
    <!-- google analytics-->

  </body>
</html>

1 个答案:

答案 0 :(得分:3)

我认为你应该给它一个名字属性。例如:

<input id="txtNane" type="text" placeholder = "Enter your Name" name="input_name">

就是这样,因为它应该是这样的:

url.domain/page.php?input_name=input_value

同样在PHP中,您可以像这样访问它:

$_GET['input_name']