diff --git a/2-ui/4-forms-controls/1-form-elements/1-add-select-option/solution.md b/2-ui/4-forms-controls/1-form-elements/1-add-select-option/solution.md index bc253e8df..80fad3850 100644 --- a/2-ui/4-forms-controls/1-form-elements/1-add-select-option/solution.md +++ b/2-ui/4-forms-controls/1-form-elements/1-add-select-option/solution.md @@ -1,4 +1,4 @@ -La soluzione, passo dopo passo: +The solution, step by step: ```html run `: +There's a ` @@ -13,10 +13,10 @@ Abbiamo un ` ``` -Usare JavaScript per: +Use JavaScript to: -1. Mostrare il valore ed il testo dell'opzione selezionata. -2. Aggiungere una option: ``. -3. Selezionarla. +1. Show the value and the text of the selected option. +2. Add an option: ``. +3. Make it selected. -Nota bene, svolgendo il compito correttamente, il tuo alert dovrebbe mostrare `blues`. +Note, if you've done everything right, your alert should show `blues`. diff --git a/2-ui/4-forms-controls/1-form-elements/article.md b/2-ui/4-forms-controls/1-form-elements/article.md index cfc270a0e..e166c8212 100644 --- a/2-ui/4-forms-controls/1-form-elements/article.md +++ b/2-ui/4-forms-controls/1-form-elements/article.md @@ -1,23 +1,23 @@ -# Proprietà dei form e metodi +# Form properties and methods -I forms e gli elementi control, come `` hanno una serie di eventi e proprietà peculiari. +Forms and control elements, such as `` have a lot of special properties and events. Lavorando con i forms, questi saranno molto comodi quando li avremo imparati. ## Navigazione: form e elements -I form del documento sono membri della speciale collezione `document.forms`. +Document forms are members of the special collection `document.forms`. -Questa è una cosiddetta "named collection": è sia associativa che ordinata. Possiamo usare sia il nome che l'indice nel documento per accedervi. +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. ```js no-beautify -document.forms.my - il form con name="my" -document.forms[0] - il primo form del documento +document.forms.my - the form with name="my" +document.forms[0] - the first form in the document ``` Quando abbiamo un form, allora tutti gli elementi saranno contenuti nella named collection `form.elements`. -Per esempio: +For instance: ```html run height=40
@@ -26,19 +26,19 @@ Per esempio:
``` -Potrebbero esserci elementi multipli con lo stesso nome, ed è una cosa che capita spesso con i radio buttons. +There may be multiple elements with the same name, that's often the case with radio buttons. -In questo caso `form.elements[name]` sarà una collezione, per esempio: +In that case `form.elements[name]` is a collection, for instance: ```html run height=40
@@ -57,13 +57,13 @@ alert(ageElems[0]); // [object HTMLInputElement] ``` -Queste proprietà di navigazione non dipendono dalla struttura dei tags. Ogni control element, è irrilevante quanto in profondità sia dentro il form, sarà contenuto ed accessibile da `form.elements`. +These navigation properties do not depend on the tag structure. All control elements, no matter how deep they are in the form, are available in `form.elements`. -````smart header="Fieldsets come \"subforms\"" -Un form può avere uno o più elementi `
` all'interno. Questi hanno anche proprietà `elements` che mostrano dei form controls all'interno. +````smart header="Fieldsets as \"subforms\"" +A form may have one or many `
` elements inside it. They also have `elements` property that lists form controls inside them. -Per esempio: +For instance: ```html run height=80 @@ -81,7 +81,7 @@ Per esempio: let fieldset = form.elements.userFields; alert(fieldset); // HTMLFieldSetElement - // possiamo ottenere l'input sia dal nome del form sia dal fieldset + // we can get the input by name both from the form and from the fieldset alert(fieldset.elements.login == form.elements.login); // true */!* @@ -92,11 +92,11 @@ Per esempio: ````warn header="Notazione breve: `form.name`" Esiste una notazione breve: possiamo accedere all'elemento come `form[index/name]`. -In altre parole, invece di `form.elements.login` possiamo scrivere `form.login`. +In other words, instead of `form.elements.login` we can write `form.login`. Funziona ugualmente, ma c'è un piccolo problema: se accediamo a un elemento, che in successivamente cambia il suo `name`, questo sarà ancora accessibile sia attraverso il vecchio nome, ma anche tramite quello nuovo. -È facile capirlo da un esempio: +That's easy to see in an example: ```html run height=40 @@ -104,34 +104,34 @@ Funziona ugualmente, ma c'è un piccolo problema: se accediamo a un elemento, ch ``` -Solitamente non è un problema, in quanto raramente andiamo a modificare il nome degli elementi dei form. +That's usually not a problem, because we rarely change names of form elements. ```` ## Backreference: element.form -Per ogni elemento, il form è disponibile come `element.form`. Quindi un form referenzia tutti gli elementi, e gli elementi referenziano il form. +For any element, the form is available as `element.form`. So a form references all elements, and elements reference the form. Come possiamo vedere in figura: ![](form-navigation.svg) -Per esempio: +For instance: ```html run height=40
@@ -149,19 +149,19 @@ Per esempio: ``` -## Elementi del form +## Form elements -Parliamo un po' dei form controls. +Let's talk about form controls. -### input e textarea +### input and textarea -Possiamo accedere ai lori valori tramite `input.value` (string) o `input.checked` (boolean) per i checkbox. +We can access their value as `input.value` (string) or `input.checked` (boolean) for checkboxes. -Come in questo caso: +Like this: ```js -input.value = "Nuovo valore"; -textarea.value = "Nuovo testo"; +input.value = "New value"; +textarea.value = "New text"; input.checked = true; // per una checkbox o un radio button ``` @@ -169,46 +169,46 @@ input.checked = true; // per una checkbox o un radio button ```warn header="Usare `textarea.value`, e non `textarea.innerHTML`" Nota bene che, nonostante anche `` contenga il suo valore come HTML annidato, non dovremmo mai usare `textarea.innerHTML` per accedervi. -Esso conterrà solamente l'HTML che era stato inizialmente impostato nella pagina, e non il valore attuale. +It stores only the HTML that was initially on the page, not the current value. ``` -### select ed option +### select and option -Un elemento `` element has 3 important properties: -1. `select.options` -- la collezione di sottoelementi `