Home  >  Article  >  Web Front-end  >  How to use HTML form components

How to use HTML form components

php中世界最好的语言
php中世界最好的语言Original
2018-01-16 09:18:251769browse

This time I will bring you the HTML form componentHow to use, how to use the HTML form component? What are the precautions when using HTML form components? The following is a practical case, let’s take a look.

HTML forms are used to collect different types of user input. The following code will share with you the example code of the html form component. Friends who are interested can refer to it.

Without further ado, I will post the code directly for you. The specific code is as follows:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="UTF-8"> 
<title>Insert title here</title> 
</head> 
<body> 
    <!-- 
    如果要给服务端提交数据 表单中的组件必须有name和value属性 
    用于给服务端获取数据  
     --> 
<from>输入名称:<input type="text" name="user" value=""/><br/> 
        输入密码:<input type="password" name="passwd" value=""/> 
        <br/> 
      选择性别:<input type="radio" name="sex" vlaue="nan"/> 男  <input type="radio" name="sex" value="nv" checked="checked"/> 女 
    <br/> 
    选择技术: 
        <input type="checkbox" name="tech" value="java"/>Java 
        <input type="checkbox" name="tech" value="html"/>html 
        <input type="checkbox" name="tech" value="css"/>CSS<br/> 
    选择文件: 
        <input type="file" name="file" /><br/> 
    一个图片:<input type="image" src="11.jpg" ><br/> 
    <!-- 数据不需要客户端指定 但是可以将其提交服务端 --> 
    隐藏组件:<input type="hidden" name="mykey" value="myvalue"/><br/> 
    一个按钮:<input type="button" value="有个按钮" onclick="alert(&#39;有个按钮&#39;)"><br/> 
    <select name="contry"> 
        <option value="none">--选择国家-</option> 
        <option value="usa">美国</option> 
        <option value="en">英国</option> 
        <option value="cn" selected="selected">中国</option> 
    </select> 
    <textarea name="text"></textarea> 
    <br/> 
    <input type="reset" value="清除数据"/><input type="submit" value="提交数据"/> 
<from> 
</body> 
</html>

I believe you have mastered the methods after reading these cases. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

How to implement calendar verification function in H5

How to obtain user geolocation in H5

How to start a colorful ring countdown with SVG

The above is the detailed content of How to use HTML form components. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn