如何使用Skeleton Boilerplate发送表单

时间:2015-04-16 18:04:15

标签: html forms skeleton-css-boilerplate

我正在使用Skeleton开箱即用,并做了一个非常简单的登陆页面。

我正在使用其网站示例(http://getskeleton.com/#forms)上提供的表单样式:

    <!-- The above form looks like this -->
<form>
  <div class="row">
    <div class="six columns">
      <label for="exampleEmailInput">Your email</label>
      <input class="u-full-width" type="email" placeholder="test@mailbox.com" id="exampleEmailInput">
    </div>
    <div class="six columns">
      <label for="exampleRecipientInput">Reason for contacting</label>
      <select class="u-full-width" id="exampleRecipientInput">
        <option value="Option 1">Questions</option>
        <option value="Option 2">Admiration</option>
        <option value="Option 3">Can I get your number?</option>
      </select>
    </div>
  </div>
  <label for="exampleMessage">Message</label>
  <textarea class="u-full-width" placeholder="Hi Dave …" id="exampleMessage"></textarea>
  <label class="example-send-yourself-copy">
    <input type="checkbox">
    <span class="label-body">Send a copy to yourself</span>
  </label>
  <input class="button-primary" type="submit" value="Submit">
</form>

<!-- Always wrap checkbox and radio inputs in a label and use a <span class="label-body"> inside of it -->

<!-- Note: The class .u-full-width is just a utility class shorthand for width: 100% -->

但是我没有看到我在哪里控制表单在提交时发送到哪里。

有人可以解释我如何使用Skeleton发送表单吗?

抱歉这个愚蠢的问题,但我迷路了。

谢谢, Melvins的

1 个答案:

答案 0 :(得分:0)

我相信他们只是给你布局html和css。您需要向表单元素提供action属性(action ='myurl')或id(id ='myform')。这是一个使用action属性的简单示例:

<p>Click 'Submit' to send the input name to 'myform.php'</p>
<form action="myform.php">
  Name: <input type="text" name="name">
  <input type="submit">
</form>

更好的是,你可以使用jQuery或javascript来设置一个事件处理程序,它将检测按钮上的点击并在任何你喜欢的地方发送表单输入数据:

$( "#myform" ).submit(function( event ) {
  alert( "name data sent to myform.php" );
  $.post( "myform.php" );
  event.preventDefault();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<p>Click 'Submit' to send the input name to 'myform.php'</p>
    <form id="myform">
      Name: <input type="text" name="name">
      <input type="submit">
    </form>