内容来自HTML Dog:http://htmldog.com/guides/html/beginner/forms/

Forms

Forms被用来收集用户的输入,它们通常被作为web应用的接口。

在实际中经常用到的相关标签 forminputtextareaselect 以及 option.

form

一个表单元素看起来是这样的

<form action="processingscript.php" method="post">

</form>

action决定表单内容将被发送到哪里。

method决定了数据的发送形式。

input

input是表单世界里的爸爸。

想看它的整个家族,请参看这里。(还有例如文件上传等等)

像br和img一样,input是不包含内容的标签,不需要“关闭”

它具有极为丰富的类型,下面仅仅是最常用的几种,认真看一下就清楚了。

textarea

<textarea rows="5" cols="20">A big load of text</textarea>

A big load of text

select

<select>
<option>Option 1</option>
<option>Option 2</option>
<option value="third option">Option 3</option>
</select>

Option 1
Option 2
Option 3

select需要和option配合使用,

提交值默认是<option></option>中间的文本,如果设置了value,那么提交的是value的值。

select也是有默认选项的,例如,在上面的代码上补充一句

<option selected>Rodent</option>

将呈现如下情景

Option 1
Option 2
Option 3
Rodent

Names

上面的标签看上去都很漂亮,

然而一旦把表单提交给一个“表单处理脚本”,它们都会被直接无视掉!!!

原因是它们没有名字!所以上面的所有标签都需要修改一下,

改成这样——>>>>> <input type="text" name="talkingsponge">.

例如:

<form action="contactus.php" method="post">

    <p>Name:</p>
<p><input type="text" name="name" value="Your name"></p> <p>Species:</p>
<p><input name="species"></p>
<!-- remember: 'type="text"' isn't actually necessary --> <p>Comments: </p>
<p><textarea name="comments" rows="5" cols="20">Your comments</textarea></p> <p>Are you:</p>
<p><input type="radio" name="areyou" value="male"> Male</p>
<p><input type="radio" name="areyou" value="female"> Female</p>
<p><input type="radio" name="areyou" value="hermaphrodite"> An hermaphrodite</p>
<p><input type="radio" name="areyou" value="asexual"> Asexual</p> <p><input type="submit"></p> </form>

Name:

Species:

Comments:

事实上我想做一个多人的文字游戏,每天更新,需要一名写手,围绕上船的人来写剧情,应该会很有意思

Are you:

Male

Female

An hermaphrodite

Asexual

一个完整的 demo

就一篇文章而言,下面的标签已经完全够用了

<!DOCTYPE html>

<html>

    <head>

        <title>My first web page</title>

        <!-- This is a comment, by the way -->

    </head>

    <body>

        <h1>My first web page</h1>

        <h2>What this is</h2>
<p>A simple page put together using HTML. <em>I said a simple page put together using HTML.</em> A simple page put together using HTML. A simple page put together using HTML. A simple page put together using HTML. A simple page put together using HTML. A simple page put together using HTML. A simple page put together using HTML. A simple page put together using HTML.</p> <h2>Why this is</h2>
<ul>
<li>To learn HTML</li>
<li>
To show off
<ol>
<li>To my boss</li>
<li>To my friends</li>
<li>To my cat</li>
<li>To the little talking duck in my brain</li>
</ol>
</li>
<li>Because I have fallen in love with my computer and want to give her some HTML loving.</li>
</ul> <h2>Where to find the tutorial</h2>
<p>
<a href="http://www.htmldog.com"><img src="http://www.htmldog.com/badge1.gif" width="120" height="90" alt="HTML Dog"></a>
</p> <h3>Some random table</h3>
<table>
<tr>
<td>Row 1, cell 1</td>
<td>Row 1, cell 2</td>
<td>Row 1, cell 3</td>
</tr>
<tr>
<td>Row 2, cell 1</td>
<td>Row 2, cell 2</td>
<td>Row 2, cell 3</td>
</tr>
<tr>
<td>Row 3, cell 1</td>
<td>Row 3, cell 2</td>
<td>Row 3, cell 3</td>
</tr>
<tr>
<td>Row 4, cell 1</td>
<td>Row 4, cell 2</td>
<td>Row 4, cell 3</td>
</tr>
</table> <h3>Some random form</h3>
<p><strong>Note:</strong> It looks the part, but won't do a damned thing.</p> <form action="somescript.php" method="post"> <p>Name:</p>
<p><input name="name" value="Your name"></p> <p>Comments: </p>
<p><textarea rows="10" cols="20" name="comments">Your comments</textarea></p> <p>Are you:</p>
<p><input type="radio" name="areyou" value="male"> Male</p>
<p><input type="radio" name="areyou" value="female"> Female</p>
<p><input type="radio" name="areyou" value="hermaphrodite"> An hermaphrodite</p>
<p><input type="radio" name="areyou" value="asexual" checked> Asexual</p> <p><input type="submit"></p> </form> </body> </html>
Advertise Here!

HTML Forms(转)的更多相关文章

  1. Wizard Framework:一个自己开发的基于Windows Forms的向导开发框架

    最近因项目需要,我自己设计开发了一个基于Windows Forms的向导开发框架,目前我已经将其开源,并发布了一个NuGet安装包.比较囧的一件事是,当我发布了NuGet安装包以后,发现原来已经有一个 ...

  2. xamarin.forms新建项目android编译错误

    vs2015 update3 新建的xamarin.forms项目中的android项目编译错误.提示缺少android_m2repository_r22.zip,96659D653BDE0FAEDB ...

  3. ASP.NET Forms 身份验证

    ASP.NET Forms 身份验证 在开发过程中,我们需要做的事情包括: 1. 在 web.config 中设置 Forms 身份验证相关参数.2. 创建登录页. 登录页中的操作包括: 1. 验证用 ...

  4. Xamarin.Forms 简介

    An Introduction to Xamarin.Forms 来源:http://developer.xamarin.com/guides/cross-platform/xamarin-forms ...

  5. C# 定时器 Timers.Timer Forms.Timer

    1.定义在System.Windows.Forms里 Windows.Forms里面的定时器比较简单,只要把工具箱中的Timer控件拖到窗体上,然后设置一下事件和间隔时间等属性就可以了 //启动定时器 ...

  6. Xamarin.Forms 免费电子书

    Xamarin Evolve 正在举行,现在已经放出2本免费的Xamarin.Forms 免费电子书,据现场的同学说这两天还有Xamarin.Forms 重磅消息发布: Creating Mobile ...

  7. 老司机学新平台 - Xamarin Forms开发框架之MvvmCross插件精选

    在前两篇老司机学Xamarin系列中,简单介绍了Xamarin开发环境的搭建以及Prism和MvvmCross这两个开发框架.不同的框架,往往不仅仅使用不同的架构风格,同时社区活跃度不同,各种功能模块 ...

  8. 老司机学新平台 - Xamarin Forms开发框架二探 (Prism vs MvvmCross)

    在上一篇Xamarin开发环境及开发框架初探中,曾简单提到MvvmCross这个Xamarin下的开发框架.最近又评估了一些别的,发现老牌Mvvm框架Prism现在也支持Xamarin Forms了, ...

  9. Nancy之Forms authentication的简单使用

    一.前言 想必大家或多或少都听过微软推出的ASP.NET Identity技术,可以简单的认为就是一种授权的实现 很巧的是,Nancy中也有与之相类似的技术Authentication,这两者之间都用 ...

  10. ASP.NET MVC4 Forms 登录验证

    Web.config配置: 在<system.web>节下: <authentication mode="Forms"> <forms loginUr ...

随机推荐

  1. source insight Confirm by typing ‘yes' below"、"has been changed outside of the editor. Do you want to reload the file?"、“

    阅读内核代码习惯和喜欢使用source insight.如果能在source insight上修改内核代码,同时又不需要把修改的内核代码再拷贝到虚拟ubuntu上去那就方便了.于是想通过用samba与 ...

  2. windows连接远程打印机

    windows连接hp的远程打印机时,自动装不了驱动.. 需打开驱动程序(驱动程序安装需接设备),然后windows就过下载驱动这步了..

  3. Material design之Views and Shadows

    Views and Shadows: elevation是构成控件阴影的基本属性.通过设置较高的Z值可以接受更大的阴影,阴影只能投射到Z=0的平面上. View Elevation 控件的Z值,是由两 ...

  4. Sublime Text 格式化代码快捷键

    首选项->按键绑定-用户 加入代码: {"keys": ["ctrl+alt+j"], "command": "reinde ...

  5. mysql "ON DUPLICATE KEY UPDATE" 的使用

    ON DUPLICATE KEY UPDATE 语法并不是SQL的标准语法,如果在句尾指定该语法,它会根据指定的主键或者唯一标示索引来更新数据库的内容 具体的操作是想根据唯一标示查看数据库是否存在该记 ...

  6. 《从零开始学Swift》学习笔记(Day54)——抛出错误

    原创文章,欢迎转载.转载请注明:关东升的博客 能放到try后面调用函数或方法都是有要求的,他们是有可能抛出错误,在这些函数或方法声明的参数后面要加上throws关键字,表示这个函数或方法可以抛出错误. ...

  7. ES6学习之Babel的正确安装姿势

    开始学习ES6,写点东西放上博客^_^ 本文介绍Babel6.x的安装过程~ 首先呢,可以使用Babel在线转换 https://babeljs.io/repl/ 然后进入主题:安装Babel(命令行 ...

  8. ClickHouse开源数据库

    ClickHouse是一个开源的面向列式数据的数据库管理系统,能够使用SQL查询并且生成实时数据报告. 优点: 1.并行处理单个查询(利用多核) 2.在多个服务器上分布式处理 3.非常快的扫描,可用于 ...

  9. 第4章 x86反汇编速成班

    4.1 抽象层次 硬件<微指令<机器码<低级语言<高级语言<解释型语言 4.2 逆向工程 4.3 x86体系结构 冯-诺依曼体系结构 中央处理器(CPU): 负责执行代码 ...

  10. for...in循环取Json数据

    var result = { "Tables":{ "B2B_DS_ORDERMX0":{ "ordernum":"tables- ...