JSP input type usage

Source: Internet
Author: User

Input indicates an input object in the form, which is divided into text input boxes, password input boxes, single choice/check boxes, and submit/Reset buttons according to the type.

 

1, type = text
The input type is text, which is the most common and most commonly used. For example, you can enter the user name, register and enter the phone number, email, home address, and so on. Of course, this is also the default input type.
Parameter Name: the name of the text input box.
Parameter size: the length of the input box.
Maxlength: the maximum number of characters allowed in the input box.
Parameter value: the default value in the input box.
Special parameter readonly: indicates that the box can only be displayed and cannot be added or modified.
<Form>
Your name:
<Input type = "text" name = "yourname" size = "30" maxlength = "20" value = "the input box length is 30, the maximum number of characters allowed is 20 "> <br>
<Input type = "text" name = "yourname" size = "30" maxlength = "20" readonly value = "You can only read and cannot modify">
</Form>

 

2, type = Password
Needless to say, the biggest difference in the password input box that you can understand at a glance is that the input information in this input box is displayed as a confidential character.
The parameter is similar to "type = text.
<Form>
Your password:
<Input type = "password" name = "yourpwd" size = "20" maxlength = "15" value = "123456"> the password length is less than 15
</Form>

 

3, type = File
What you need when uploading images in BBS and uploading attachments in email :)
Provides a platform for inputting file directories. The parameters include name and size.
<Form>
Your file:
<Input type = "file" name = "Yourfile" size = "30">
</Form>

 

4, type = hidden
It is worth noting that a domain is often called a hidden domain: if a very important information needs to be submitted to the next page, but it cannot or cannot be expressed explicitly.
In a word, you cannot see where hidden is on the page. The most useful value is the value of hidden.
<Form name = "form1">
Your hidden info here:
<Input type = "hidden" name = "yourhiddeninfo" value = "cnbruce.com">
</Form>
<SCRIPT>
Alert ("the value of the hidden field is" + document. form1.yourhiddeninfo. value)
</SCRIPT>

5, type = button
Standard windows-style buttons, of course, to redirect the buttons to a page, you also need to add JavaScript code
<Form name = "form1">
Your button:
<Input type = "button" name = "yourhiddeninfo" value = "Go, go, go! "Onclick =" window. Open ('HTTP: // www.cnbruce.com ') ">
</Form>

6, type = checkbox
Multi-choice box. It is common to select hobbies, personalities, and other information during registration. Parameters include name, value, and special parameters checked (which indicates the default value)
In fact, the most important thing is the value, which is the value submitted to the processing page. (Note: The name value can be different, but it is not recommended .)

<Form name = "form1">
A: <input type = "checkbox" name = "checkit" value = "A" Checked> <br>
B: <input type = "checkbox" name = "checkit" value = "B"> <br>
C: <input type = "checkbox" name = "checkit" value = "C"> <br>
</Form>
The name value can be different, but it is not recommended <br>
<Form name = "form1">
A: <input type = "checkbox" name = "checkit1" value = "A" Checked> <br>
B: <input type = "checkbox" name = "checkit2" value = "B"> <br>
C: <input type = "checkbox" name = "checkit3" value = "C"> <br>
</Form>

7, type = radio
That is, the single-choice option appears in the page setting for multiple choices. Parameters also include name, value, and special parameter checked.
Different from checkbox, the name value must be the same; otherwise, you cannot select one more. Of course, the value is also submitted to the processing page.

<Form name = "form1">
A: <input type = "radio" name = "checkit" value = "A" Checked> <br>
B: <input type = "radio" name = "checkit" value = "B"> <br>
C: <input type = "radio" name = "checkit" value = "C"> <br>
</Form>
The following is an example of a different name value. You cannot select multiple values. <br>
<Form name = "form1">
A: <input type = "radio" name = "checkit1" value = "A" Checked> <br>
B: <input type = "radio" name = "checkit2" value = "B"> <br>
C: <input type = "radio" name = "checkit3" value = "C"> <br>
</Form>

8, type = image
One of them is more alternative. Let's take a look at the effect. It can be used as a submitted image.

<Form name = "form1" Action = "XXX. asp">
Your imgsubmit:
<Input type = "image" src = "../blog/images/face4.gif">
</Form>

9, type = submit and type = Reset
The buttons are "Submit" and "reset ".
The main function of submit is to submit all content in the form to the action page for processing, and reset is to quickly clear all filled content.

<Form name = "form1" Action = "XXX. asp">
<Input type = "text" name = "yourname">
<Input type = "Submit" value = "Submit">
<Input type = "reset" value = "reset">
</Form>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.