The creation of that robot with forms in html. Select from list in HTML html drop-down list is displayed only once

Even more often when registering or surveying on sites, you are asked to fill in select from the list. For example, choose your country from many other countries. All the main elements are formed, the stench can be and in a different design: in the form of a simple HTML5 up to folding CSS3.

Today, we will choose one of such examples of the design of the field for selection, zastosovuchi HTML/CSS that icon Font Awesome. Ale, let's start by ringing out the document's outlines.

HTML code

Inside the tag select be found in the dropdown list option. Have your own line, tags selectі form deposits in the fire container div. Tag form owe buti obov'yazkovo, yakschcho zgodom will be sent to the server.







Positioning container from class box at the center of the window.

Box(
position: absolute;
top: 50%;
left: 50%
transform: translate(-50%, -50%);
}

Add an icon font before the tag that closes head.

Styling the select selector

Set the size for the selection field - 250x50 pixels, and the field for points is 10 pixels each from the sides.

Box select(
width: 250px
height: 50px;
padding: 10px
}

We take the frame and the circle:

Border: none
outline: none;

We will write a purple color for the background, name, color and size for the font for lists.

Background: #ab05af;
font-family: "Russo One", sans-serif;
color: #fff;
font-size: 20px;

We create near the field of darkness.

box-shadow: 0 5px 20px rgba(0,0,0,.3);

In general select box get ready and practice, but look at you tediously, that tricoutnik, in which you will need to eat a little bear with a bear. And if I think so, it means that the designer will think, it is necessary to get ready for different options.

Nayimovіrnіshe designer to put on the plate of the knitted tricot - an icon in the font Font Awesome.

You look so richly beautiful, but writing the code is all the same required by the coder. How can there be a solution here? We are not chipatimemo HTML code, and the pseudo-element before.

Before pseudo-element for .box

First, what you need to do is to write down the code of the icon and I will name the font "Font Awesome 5 Free". Selected on site fontawesome.com I will need an icon that means "choose" and a copy of your code.



.box::before (
content: "\f150";
font-family: "Font Awesome 5 Free";
position: absolute;
top: 0;
right: 0;
width: 50px
height: 50px;
text-align: center;
line-height: 50px
color: #fff;
font-size: 28px;
background: #da00e0;
pointer-events: none;
}

We gave the position absolutely, it is possible to expand 50x50, the icon has a white color, a light purple background. We ask the most important authority pointer-events: none. Tse means that the pseudo-element before not an object under the mouse, but a meaning none proponu podії under the "selection of a bear" go to the lower ball and turn up to the element that you know under it - to a small tricoutnik. Trikutnik didn’t know anywhere, it’s just that the vin is rebuying under the pseudo-element before, scho to serve as an embellishment. Clicking on the beautiful end, really spratsovu "ugly" trikutnik, and mi robimo your choice.

window.onresize = ...;

Podіya onresize of the object window vіdpovіdaє for changing the size of the window of the browser. Therefore, it is necessary to lay the object of the window - window.

Since there is no tag in the middle of the html elements, which is displayed by the browser window, then you can convert the onresize subdial in JavaScript for the help of using the power function of the window object.

Let's take a look at the example:

Butt: Write a script that, when changing the rozmіru vikna, will call out the notification "Rozmir vikna changed!"


Script:

window.onresize = function message() (alert("Window size has been changed!");)

HTML code:

be kind, change the rozmіr vіkna.

Object javascript list, what to see - select

The select object is a list that you select - gives a list of values ​​to select. Choice can be as one point, and a number of points in a row. The name of the collapsible object that the script requires to be used before the select object, as well as the option item.

The power of the select object:

  • length - number of items in the list
  • name - the name attribute
  • options - array of items
  • selectedIndex - the index of the selected option item
  • defaultSelected - selection of the option item for locking
  • selected - selected item

You can set the value of a list (select) in javascript through the power of value . Ale є th іnshі methods.

Let's look at the example:

Butt: Make a list that you can see from three points - cities: Moscow, St. Petersburg, other. By clicking on the button, select the power value of the selected option (item) list and display it on the screen


HTML code:
<formname="f1"> Location:<br > <select name="town" id="s1" > <option value = "(!LANG:(!LANG:msk" > !}!} Moscow</option> <option value = "(!LANG:(!LANG:spb" > !}!} St. Petersburg</option> <option value = "(!LANG:(!LANG:other" > !}!} other</option> </select> <input type = "button" onclick = "f()" value = "(!LANG:(!LANG:ok" > !}!} </form>

Location:

List value identification:

function f() ( var a= document.getElementById ("s1" ) .value ; alert(a) ; )

function f()( var a=document.getElementById("s1").value; alert(a); )

Manager js13_1. When changing a list item, add a text field with the text from the selected menu item (option).

Detail:

  • Add a text box and a select list with options with text.
  • For the tag that is in the select curve, add the onchange subscript.
  • Display the onchange subscript with a function that changes the text in the text field (put the value of the selected menu item in the text field).

Add code:

Script:

function check() ( document.getElementById("t1") .value = ...; )

function check() ( document.getElementById("t1").value= ...; )

<input type="text" id="t1"> <br > <select id="menu1" onchange="..." > <option value = "1" > 1</option> <option value = "2" > 2</option> <option value = "3" > 3</option> </select>


Manager js13_2. Create a reversal of knowledge about nutrition: "Which kind of loneliness is the world's robot?" that two statements: "Mil"(incorrect) that "Joule"(correct), viconymy as a menu item with a list (select). Run the recheck function



Let's take a look at the example of the power of the object select - selectedIndex - select option item:

Butt: Enter the index of the selected alternative in the text box:

Car factory: Selected index:

For this application, when changing the menu item, the onChange subpoya is generated. As the value of the onChange attribute, the script is retrieved: access to the text field through the array of elements in the form (the text field is the first element in the array, so the 0th element is the select list, which disappears). The number of the selected list (selectedIndex) is specified as the value of the text field.

javascript option object - menu item

The select menu item in javascript - option - is seen as an object with its powers:

Access to a specific menu item is via collection (array) options:

<formname="f1"> <selectname="s1"> <option value = "1" > 1</option> <option value = "2" > 2</option> <option value = "3" > 3</option> </select>

Script to access the first menu item (zero element in the options array):

function myFunc()( document.f1.s1.options....=...; ...; )

Let's take a look at the example of using the power of the text object option:

Butt: When changing the selection of the list in the text field, enter the text from the selected alternative to the list

<form > <select id="s1" onChange= "document.getElementById("t1").value= document.getElementById("s1").options.text;"> <option > GAS<option > VAZ</select> <input type="text" id="t1"> </form>

Let's take a look at one more solution from the multiple choice list:

Butt: When changing the list of multiple choices, the text window displays the index of the selected alternatives
(Insert the multiple attribute on the list)



<form > Set of office supplies:<select onChange = "form.elements.value=""; for(i=0;i<6;i++) if(form.elements.options[i].selected==true) form.elements.value = form.elements.value+i;" multiple> <option > Olivtsi<option > Fountain pens<option > Lines<option > Zoshiti<option > Sterki<option > Buttons</select> Selected positions:<input name="s1" size="7" maxlength="7"> </form>

Set of office supplies: Selected positions:

Butt:

Butt: By clicking on a paragraph (tag p) change the text of the given tag and center the text in the new one

<p onclick = "this.outerHTML="

change text</p>"">Change room</p>

change text

"">Change room

How do you know what your current website design is? Why won't you win the rest of the technology, or are you afraid of them? It’s possible, you think, that it’s too foldable and you don’t want to lie in the net. Ale, it’s true, everything else. Even new technologies (I can use CSS3 now) came to make life easier for a web designer and bring their own abilities while creating a modern looking site. Today, let's talk about those swatches of design for the list that you see.

List of what you see for the site

It’s not the simplest decision I’ve looked at in the world of the rock 🙂:

take advantage

What I want to say in front of the demo drive: the skin of the okremium type of the list is in the okremі HTML file, which allows you to easily take the code that you need. Also, in the other files, the styles of skin design are listed. You no longer have to choose the one that suits you best and know your style file.

There is nothing unusual about the list:

1 2 3 4 5 6 7 8 9 10
<label class="select-label"> Choose your dinosaur:</label> <select class="cs-select cs-skin-rotate" > <option value = "1" > Stegosaurus</option> <option value = "2" > Velociraptor</option> <option value = "3" > Spinosaurus</option> <option value = "4" > Archeopteryx</option> <option value = "5" > Apatosaurus</option> </select> </section>

How to say: . Use the middle of the new tags , where to find the elements of the list.

For some butts, you can add non-primary attributes to the type data-class or data link. There is nothing to be afraid of, the stench is necessary for the correct functioning of the list, because additional information can be saved.

Let's go through the styles.

The main styles are found in the file cs-select.css. There are styles here that give the list a unique look that we call bachiti.

And in order to make the style unique and original, it is necessary to win the additions of power. For example, for the first butt () the following styles are used:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 @font-face ( font-family : "icomoon" ; src: url ( "../fonts/icomoon/icomoon.eot?-rdnm34"); src:url( "../fonts/icomoon/icomoon.eot?#iefix-rdnm34") format("embedded-opentype" ) , url ( "../fonts/icomoon/icomoon.woff?-rdnm34") format("woff") , url ( "../fonts/icomoon/icomoon.ttf?-rdnm34") format("truetype" ) , url ( "../fonts/icomoon/icomoon.svg?-rdnm34#icomoon") format("svg"); font-weight: normal font-style: normal ) div.cs-skin-border ( background : transparent ; font-size : 2em ; font-weight : 700 ; max-width : 600px ; ) @media screen and (max-width: 30em) (.cs-skin-border ( font-size : 1em ; ) ) .cs-skin-border > span ( border : 5px solid #000 ; border-color : inherit ; transition : background 0.2s, border-color 0.2s; ) .cs-skin-border > span: :after , .cs-skin-border .cs-selected span: :after ( font-family : "icomoon" ; content : " \e000"; ) .cs-skin-border ul span: :after ( content : "" ; opacity : 0 ; ) .cs-skin-border .cs-selected span: :after ( content : " \e00e"; color: #ddd9c9; font-size: 1.5em opacity: 1 transition: opacity 0.2s; ) .cs-skin-border .cs-active > span ( background : #fff ; border-color : #fff ; color : #2980b9 ; ) .cs-skin-border .cs-options ( color : #2980b9 ; font- size : 0.75em ; opacity : 0 ; transition : opacity 0.2s, visibility 0s 0.2s; ) .cs-skin-border .cs-active. skin-border ul span ( padding : 1em 2em ; backface-visibility : hidden ; ) .cs-skin-border .cs-options li span:hover , .cs-skin-border li.cs-focus span ;)

And to know the styles in the okremy file (for clarity) cs-skin-border.css.

Visnovok

Just don't do it for the unique design of your site! First smut - don't be afraid to experiment with design, gradually paint yoga. Raptome you create (through a path of experiments) the very one that suits your koristuvach and stinks to say “Wow, I like this design, what else is there on this site!” 😉 .

The simplest list you can see in HTML is easy to create with the select tag. The tag-container, the option tags are nested in the new one - the stink itself is set to the list element.

There are a number of options in lists, so you can search for additional select tags: a list to expand (options can be selected after clicking on the main field or hovering over a new cursor) and a list of multiple selections - in the new box, you can select a few items. The first widest, є significant element of navigation of modern sites. A list of multiple choices, which you can see, you can zastosuvati, for example, in catalogs, de need to select a few characteristics of a product.

You can change the current look and power of the lists with the help of universal and special attributes.

select tag attributes

1. Multiple - set multiple choices.

2. Size - sets the number of visible rows in the list, that is the height. І here everything is left to fall in order, є the attribute multiple chi nі. If so, if you do not specify the size, then for the presence of multiple coristuvach you can select all possible options for selection, if multiple times a day, then there will be less than one row of readings, and you can read the answer if you click on the elevator icon from the right side. Since the height of size is set and won't be less for the number of options, then the scrolling will appear on the right.

3. Name - im'ya. The list that you can see can be done without it, but it can be necessary for interaction with the program-computer on the server. As a rule, im'ya still tell.

The select tag doesn't have language attributes, but the option tag is visible.

Nested option tag attributes

  1. Selected - assignments for the item to the list. The box can see more than one item, as long as the multiple attribute is set (div. more).
  2. Value - value. Tsey attribute is obov'yazkovim. The web server is to blame for the change, yakі items in the list by selecting koristuvach.
  3. label. For the help of this attribute, you can skip over other elements of the lists. For example, “Milan” appears on the screen, instead of the one indicated in the abstract option “Milan is the administrative center of Lombardy. Pivnichna Italy. This attribute is also selected for grouping items in the list.

According to the width of the list, then it will be installed behind the lock for the longest text on the list. Obviously, the width can be changed with additional HTML styling.

List of what you see in other ways

You can use it for additional CSS, for example, the list appears when you hover over the side element. You can use JavaScript to create lists, which the Jquery library will ask the robot to do. The list of connections for the help of the library can be more collapsible, for example, cascading. So when you select an element in one list, the next list is displayed, for example, use the menu item "Lady's clothes" (when hovering, it will disappear when you select one of the views, for example, "Top clothes", you will see a list with elements: jackets, parkas, coats, napіvpalto, fur coat skinny.

We overhauled the main methods, for the help of which you can create a list of what you can see. Understandably, there are a lot of nuances in JavaScript, which allow you to change the functionality and look of lists.

Hello, new readers of the blog site. As part of the exercise of wisdom, as a clergyman, we continue to sort out the details of the creation of forms on the site for help.

Today we will decide how to create lists that fall out (open up), including those with a multiple choice, for the additional select and option, in which order to construct text field for the help of a text writer, and also let's talk about the possibility of expanding the functionality of forms by way of adding tags fieldset, label and legend.

I’m wondering if it’s a form, if it’s on the side, it’s created for help and is recognized for the introduction of whether it’s information in the form of a coristuvacha and an amendment to the server (butt -).

It's a pity, the help of hypertext layouts does not allow you to process this information without intermediary, so for the help of HTML we create only a better-looking form, and the necessary data is forced for processing. With this method, a special file is created on the webserver, written one of the server mov (mostly PHP). Let's say, for a good connection, you can create a mail.php file, which will be a collector.

With a practical choice of otrimano in your publication of information, do not forget about those that can look decode all visible elements of the side, including forms, must always be in the boundaries of the body tag.

Ця інформація вкрай необхідна, оскільки навіть у разі використання всіх сучасних вбудованих інструментів розробників (нагадаю, першою ластівкою в реалізації цього функціоналу був ), ви повинні чітко уявляти собі механізм використання основних тегів, тоді редагування коду HTML, необхідність якого виникає час від часу, перетвориться busy at the reception.

2. multiple- this attribute, which does not have parameters, gives the possibility of a multiple choice on the view of the pointed butt, it is possible to select only one element (row). Try to see in this list with a bear in a row a sprat of rows (one at a time in some places, pressing the Ctrl key, or for the help of Shift coming one by one):

3. size- set the height of the list, which you see, so that the number of rows, which are displayed. If there is a multiple attribute, and the size value is not specified (as in the application), then for promotions, chotiri rows are brought up, and, for example, with size="5" you will already see five:

Option Textarea Label Fieldset Legend

4. Required(Parameters are not possible) - signify that obov'yazkovo needs to make a choice before correcting the data collection. If an element is not included in the list, this form will not be edited:

Option Textarea Label Fieldset Legend

5. auto focus(does not have a value) — sets the focus on the list once the page is taken. In addition, as the sound of the main part of the main part of the work of the keys, then the very same front-lined focusing to help the work of the selection of the list for the additional arrows on the keyboard without any kind of bear:

6. Disabled(No parameters) — blocks access to the list (enables it). In practice, sound victorious at the same time with scripts in quiet moods, if it is necessary to include a list of what is revealed, only when singing minds are victorious:

7. Form link to the list with one or more forms, to lie down to some wines, but to know the position of the container

. With this, the parameter is written in the role of the value of the form attribute global id attribute, which is added before the form tag:

Remove from list Option Textarea Label Fieldset Legend

Don't confuse the select tag attribute with the main tag for folding the form. The application has the id="data" attribute before the form tag, and the form="data" attribute before the select tag, which allowed the list to be linked to a specific form.

option tag attributes

1. value- assign those values ​​to the list, as if they would be sent to the server (formation form). Well, the sample is corrected by name, as it is set by the name attribute of the select tag, that value(for this butt - 1, 2, 3, 4, 5)

Option Textarea Label Fieldset Legend

2. Disabled- blocks for selecting an element in the list that you can see.

Option Textarea Label Fieldset Legend

As you can see from the butt, the “Option” row is inactive and it is impossible to select it.

3. label— displays a textual change (what is the meaning of) of that other list. If the label is present, then a row is displayed that has the same value as the attribute and ignores the textual space that is in the middle of the option tag. Those same vіdbuvaєsya, yakscho vmіst mizh zovsіm vіdsutnya.

Textarea tag Label tag Fieldset tag Legend tag

Marvel. For the hovered application, the first row for the option is for the empty code (at the left side of the table), and for the prescriptions, the parameter label="Option tag", as a result, the text itself appears in the list (at the right side). Another line of code is to replace the option tag with the text "Tag Textarea", and in the list on the right, the word "Textarea" is displayed, which matches the value of label="Textarea".

4. Selected— see the current item in the list:

Option Textarea Label Fieldset Legend

Also, the multiple attribute, so that more than one element can be seen:

Option Textarea Label Fieldset Legend

optgroup tag attributes

If the list, which appears, needs to be sorted, for example, divided into groups, then for the skin of these groups, vicorist container, which is formed by opening and closing the tags of the optgroup, in the middle of which there is a part of the points in the drop-down list. With this, two attributes are used to create a similar list that is being developed.

1. label— set the name of the skin group as a parameter:

Option Textarea Label Fieldset Legend

The same, but with multiple and size="7" of the select tag:

Option Textarea Label Fieldset Legend

2. Disabled(no value) - blocking the choice of elements in those groups, as many as 100 of the installations, and inactive points sound the vision with a similiar color:

Option Textarea Label Fieldset Legend

A small video clip will be more useful here:

Text field near the form for additional text

Another element of the form for the site, which is visible to the world - a field with the possibility of entering up to a new rich text. Yoga can be done with the help of the textrea tag. Without attributes for capturing, adding this tag will give the following result:

Enter text:

Enter text:

At the field, you can change the transfer of rows, with which the text is transferred to the collector on the server with the correction of broken transfers. The field can be stretched along the width and length, having buried the lower right corner with a bear, which is designated by two diagonal females.

Let's try now to add to the cob code a spear of attributes from the parameters:

1. Name- designate the name of the text area as a value for identifying after the power of these forms for the hour of processing on the server.

2. Cols— the width of the field, as in the role of the parameter, is set by the number of the same symbols to stand on, placed horizontally. Value for loot - 20.

3. Rows- The height of the text field, which is determined by the number of rows. If there are a lot of rows in the text, which should be introduced by a shorthand, appear more for the value given by the attribute, then the right-hander will appear vertically scrolling.

4. Maxlength— Specify the maximum number of characters that can be placed in the text field. If the limit is moved further, the introduction will be impossible.

Below, the butt is pointed with the use of more refurbished attributes, you can interpret them especially for the skin one, simply by placing a number of letters and rows in the text area (you can simply enter one and the same character of the number of times):

Enter text:

Enter text:

5. minlength— indicate the minimum number of characters that should be entered in the text area. If you try to send a text with a smaller number of characters, then the browser will display a brief summary of the information, in order to solve the riddle about the need to add additional forms and about those symbols already entered.

7. Readonly(without parameters) - if you screw the attribute to the textarea, then the text field will appear as inaccessible change boxes and will be recognized as unreadable. And you can focus on the new one (move the cursor to the field and click the left button of the bear), as well as see and copy (often or repeat) the text:

Another piece of attributes that implement additional functionality for the hour of filling watering:

8. Autocomplete- indicate that the browser is to blame for seeing the hints when filling in the form of the text on the data that was previously entered, and giving the ability to automatically insert the correct text.

May everything two parameters: on(included) that off(Wimmed). Axis butt code:

Enter text:

This attribute with the value "on" is only applicable if the web browser of a particular user has autocomplete form fields enabled.

9. Wrap- Install for the browser the rules for transferring rows in the text area for an additional three values:

Soft- a set of characters, which does not move in the field beyond the width, is automatically transferred to a new row. At what obrobnik the text will be transferred in the view of one row. In that case, if you want to transfer the text in any necessary place for the help of the “Enter” key, then transferring is saved for an hour of overpowering the web form.

Enter text:

Enter text:

Hard- transfer the changes automatically, so that the text does not fit in the field in width, moreover, if the copy is overstretched, the space for such transfers will be saved. This parameter is victorious only in linking to the cols attribute:

Enter text:

Enter text:

Off- Inclusion of transfers of rows. If you want to override a text fragment without mechanically transferring it after the additional “Enter” key, the entire text will be placed in one row, moreover, a horizontal swag will appear:

Enter text:

Enter text:

10. auto focus(no parameters) — initiating focusing on the text field for the hour of focusing on the side with the form.

11. Disabled- on the view of the readonly attribute (which also hinders the editing of the fields, but also gives the ability to focus on a new one), I will block access to the text area again, so that it sounds like a Syrian color: