Update article.md

Minor edits for grammar, phrasing, and markup.
This commit is contained in:
Zearin 2021-01-15 12:14:53 -05:00 committed by GitHub
parent f797858498
commit bda37e2b7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8,7 +8,7 @@ Working with forms will be much more convenient when we learn them.
Document forms are members of the special collection `document.forms`.
That's a so-called "named collection": it's both named and ordered. We can use both the name or the number in the document to get the form.
That's a so-called <dfn>"named collection"</dfn>: it's both named and ordered. We can use both the name or the number in the document to get the form.
```js no-beautify
document.forms.my - the form with name="my"
@ -36,9 +36,9 @@ For instance:
</script>
```
There may be multiple elements with the same name, that's often the case with radio buttons.
There may be multiple elements with the same name. This is often the case for radio buttons or checkboxes.
In that case `form.elements[name]` is a collection, for instance:
In these cases, `form.elements[name]` is a _collection_. For instance:
```html run height=40
<form>
@ -119,7 +119,7 @@ That's easy to see in an example:
</script>
```
That's usually not a problem, because we rarely change names of form elements.
That's usually not a problem, however, because we rarely change names of form elements.
````
@ -182,7 +182,7 @@ A `<select>` element has 3 important properties:
They provide three different ways of setting a value for a `<select>`:
1. Find the corresponding `<option>` element (e.g. among `select.options`) and set its `option.selected` to `true`.
1. Find the corresponding `<option>` element (e.g., among `select.options`) and set its `option.selected` to `true`.
2. If we know a new value: set `select.value` to the new value.
3. If we know the new option number: set `select.selectedIndex` to that number.
@ -204,7 +204,7 @@ Here is an example of all three methods:
</script>
```
Unlike most other controls, `<select>` allows to select multiple options at once if it has `multiple` attribute. This attribute is rarely used though.
Unlike most other controls, `<select>` allows to select multiple options at once if it has `multiple` attribute. This attribute is rarely used, though.
For multiple selected values, use the first way of setting values: add/remove the `selected` property from `<option>` subelements.
@ -246,7 +246,7 @@ This syntax is optional. We can use `document.createElement('option')` and set a
The difference between `defaultSelected` and `selected` is that `defaultSelected` sets the HTML-attribute (that we can get using `option.getAttribute('selected')`, while `selected` sets whether the option is selected or not.
In practice, we usually should set both values to `true` or `false` (or omit, that's the same as `false`).
In practice, you should usually set _both_ values to `true` or `false` (or omit; that's the same as `false`).
For instance, here's a new "unselected" option:
@ -289,9 +289,9 @@ Form navigation:
`element.form`
: Elements reference their form in the `form` property.
Value is available as `input.value`, `textarea.value`, `select.value` etc, or `input.checked` for checkboxes and radio buttons.
Value is available as `input.value`, `textarea.value`, `select.value`, etc. (or `input.checked` for checkboxes and radio buttons).
For `<select>` we can also get the value by the index `select.selectedIndex` or through the options collection `select.options`.
For `<select>`, we can also get the value by the index `select.selectedIndex` or through the options collection `select.options`.
These are the basics to start working with forms. We'll meet many examples further in the tutorial.