html中表单的应用

HTML表单(F <script type=text/javascript>arw("FR", ark7);</script> orm)是HTML的一个重要部分,主要用于采集和提交用户输入的信息。

用checked表示缺省已选的选项!

举个简单的例子,一个让用户输入姓名的HTML表单(Form) <script type=text/javascript>arw("-6s", ark0);</script> 。示例代码如下:

<form action="http://www.blabla.cn/asdocs/html_tutorials/yourname.asp" method="get">

请输入你的姓名:

<input type="text" name="yourname">

<input type <script type=text/javascript>arw("@Z@hiJzVYnW8", ark2);</script> ="submit" value="提交">

</form>

演示示例

学习HTML表单(Form)最关键要掌握的有三个要点:

  • 表单控件(Form Controls)
  • Action
  • Method

演示示例 或者从选项中选择。

先说表单控件(Form Controls),通过HTML表单的各种控件,用户可以输入文字信息,或者从选项中选择,以及做提交的操作。比如上面的例句里 <script type=text/javascript>arw("}sj", ark5);</script> ,input type= <script type=text/javascript>arw("=WJukO;", ark5);</script> "text"就是一个表单控件,表示一个单行输入框。

用户填入表单的信息总是需要程序来进行处理,表单里的action就指明了处理表单信息的文件。比如上面例句里的http://www.blabla <script type=text/javascript>arw("?c", ark0);</script> .cn/asdocs/html_tutorials/yourname.asp。

至于method,表示了发送表单信息的方式。method有两个值:get和post。get的方式是将表单控件的name/value信息经过编码之后 <script type=text/javascript>arw("$HI", ark4);</script> ,通过URL发送(你可以在地址栏里看到)。而post则将表单的内容通过http发送,你在地址栏看不到表单的提交信息。那什么时候用get,什么时候用post呢?一般是这样来判断的,如果只是为取得和显示数据,用get;一旦涉及数据的保存和更新,那么建议用post <script type=text/javascript>arw("#4V", ark5);</script> 。

HTML表单(Form)常用控件(Controls)

HTML表单(Form)常用控件有:

  • input type="text" 单行文本输入框
  • input type="submit" 将表单(Form)里的信息提交给表单里action所指向的文件
  • input type <script type=text/javascript>arw(">L>3QDFHy", ark7);</script> ="checkbox <script type=text/javascript>arw("?UA4m3p", ark0);</script> " 复选框
  • input type="radio" 单选框
  • select 下拉框
  • textArea 多行文本输入框
  • input type="password" 密码输入框(输入的文字用*表示)

表单控件(F <script type=text/javascript>arw("^l", ark0);</script> orm Control):单行文本输入框(input type="text")

单行文本输入框允许用户输入一些简短的单行信息,比如用户姓名。例句如下:

<script type=text/javascript>arw("?4s3d", ark1);</script> <input type="text" name="yourname">

演示示例

表单控件(F <script type=text/javascript>arw("^l", ark0);</script> orm Control):复选框(input type="checkbox")

复选框允许用户在一组选项里,选择多个。示例代码:

<script type=text/javascript>arw(">A4QV", ark7);</script> <input type="checkbox" name="fruit" value <script type=text/javascript>arw("=t@amNoxc", ark5);</script> ="apple">苹果 <script type=text/javascript>arw("?U;7B", ark0);</script> <br <script type=text/javascript>arw("?4Z3d", ark1);</script> >

<input type <script type=text/javascript>arw("=t@amNoxc", ark5);</script> ="checkbox" name="fruit" value ="orange">桔子<br>

<input type="checkbox" name="fruit" value ="mango">芒果<br>

演示示例

用checked表示缺省已选的选项。

<input type="checkbox" name="fruit" value ="orange" checked>桔子<br>

演示示例

表单控件(Form Control):单选框(input type="radio")

使用单选框 <script type=text/javascript>arw("!UE", ark6);</script> ,让用户 <script type=text/javascript>arw("%o8", ark3);</script> 在一组选项里只能选择一个。示例代码:

<input type="radio" name="fruit" value = "Apple">苹果<br>

<input type="radio <script type=text/javascript>arw("@yNlgK0", ark2);</script> " name="fruit" value = "Orange <script type=text/javascript>arw("?4z0Kkl?jKP2", ark1);</script> ">桔子<br>

<input type <script type=text/javascript>arw(">L>3QDFHy", ark7);</script> ="radio" name="fruit" value <script type=text/javascript>arw("?T", ark1);</script> = "Mango">芒果<br <script type=text/javascript>arw("@y3mH", ark2);</script> >

演示示例

用checked表示缺省已选的选项 <script type=text/javascript>arw("(Mh", ark2);</script> 。

<input type="radio" name <script type=text/javascript>arw("=t@amNoxc", ark5);</script> ="fruit <script type=text/javascript>arw("@9ilPV0", ark4);</script> " value = "Orange" checked>桔子<br>

演示示例

表单控件(Form Control):下拉框(select)

下拉框(Select)既可以用做单选,也可以用做复选 <script type=text/javascript>arw(")W;", ark1);</script> 。单选例句如下:

<select name="fruit" >

<option value <script type=text/javascript>arw("=J=6SOIFf", ark3);</script> ="apple">苹果

<option value="orange">桔子

<option value="mango">芒果

<script type=text/javascript>arw("@9dmY", ark4);</script> </select>

演示示例

如果要变成复选,加muiltiple即可 <script type=text/javascript>arw("#4V", ark5);</script> 。用户用Ctrl来实现多选。例句:

<select name="fruit" multiple>

演示示例

用户还可以用size属性来改变下拉框(Select)的大小。

演示示例

表单控件(F <script type=text/javascript>arw("IT", ark3);</script> orm Control):多行输入框(textarea)

多行输入框(textarea)主要用于输入较长的文本信息。例句如下:

<script type=text/javascript>arw("@ySmH", ark2);</script> <textarea name="yoursuggest" cols ="50" rows = "3"></textarea>

其中cols表示textarea的宽度,rows表示textarea的高度 <script type=text/javascript>arw(")W;", ark1);</script> 。

演示示例

表单控件(Form Control):密码输入框(input type="passw <script type=text/javascript>arw("IT", ark3);</script> ord")

密码输入框(input type="password <script type=text/javascript>arw("@yNlgK0", ark2);</script> ")主要用于一些保密信息的输入,比如密码 <script type=text/javascript>arw("#4V", ark5);</script> 。因为用户输入的时候,显示的不是输入的内容,而是黑点符号 <script type=text/javascript>arw("-6s-6s", ark0);</script> 。。例句如下:

<input type="password" name="yourpw">

演示示例

表单控件(Form Control):提交(input type="submit <script type=text/javascript>arw("=CKOQNf", ark3);</script> ")

通过提交(input type=submit)可以将表单(Form)里的信息提交给表单里action所指向的文件 <script type=text/javascript>arw("(Mh", ark2);</script> 。例句如下:

<input type <script type=text/javascript>arw("=J=6SOIFfMG7", ark3);</script> ="submit" value="提交">

演示示例

表单控件(Form Control):图片提交(input type <script type=text/javascript>arw("?T>QInCP2", ark1);</script> ="image")

input type=image 相当于 input type=submit,不同的是,input type=image 以一个图片作为表单的提交按钮 <script type=text/javascript>arw("!UE", ark6);</script> ,其中 src 属性表示图片的路径。

<input type="image" src ="http://www.blabla.cn/images/icons/go.gif"

alt = "提交" NAME="imgsubmit">

演示示例

用checked表示缺省已选的选项。

如何编写 <script type=text/javascript>arw("gq", ark3);</script> ASP 网页获取 HTML 表单的提交信息,请参见教程:ASP和HTML表单。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值