You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 2-ui/4-forms-controls/1-form-elements/article.md
+20-19Lines changed: 20 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,24 @@
1
-
# Form properties و methodها
1
+
# Form properties و methods
2
2
3
3
فرمها و control elementها مثل `<input>` دارای prperty و eventهای ویژهای هستند.
4
4
5
5
وقتی فرمها را یاد بگیریم، کار کردن با آنها بسیار راحتتر میشود.
6
6
7
7
## Navigation: form and elements
8
8
9
-
Document forms are members of the special collection `document.forms`.
9
+
فرمهای document از اعضای مجموعهی ویژهی `document.forms` هستند.
10
+
11
+
این به اصطلاح یک مجموعهی نامگذاری شده است: هم نامگذاری شده و هم ترتیبدار شده است. برای دسترسی به فرم میتوانیم هم از نام آن و هم از شمارهی آن در document استفاده کنیم.
10
12
11
-
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.
12
13
13
14
```js no-beautify
14
-
document.forms.my; //the form with name="my"
15
-
document.forms[0]; //the first form in the document
15
+
document.forms.my; // "my" = فرم با نام
16
+
document.forms[0]; //document اولین فرم در
16
17
```
17
18
18
-
When we have a form, then any element is available in the named collection`form.elements`.
19
+
وقتی یک فرم داریم، در این صورت هر elementای در مجموعهی نامگذاری شده با`form.elements` قابل دسترسی است.
19
20
20
-
For instance:
21
+
برای مثال:
21
22
22
23
```html run height=40
23
24
<formname="my">
@@ -26,19 +27,19 @@ For instance:
26
27
</form>
27
28
28
29
<script>
29
-
//get the form
30
+
// form گرفتن
30
31
let form =document.forms.my; // <form name="my"> element
31
32
32
-
//get the element
33
+
// element گرفتن
33
34
let elem =form.elements.one; // <input name="one"> element
34
35
35
36
alert(elem.value); // 1
36
37
</script>
37
38
```
38
39
39
-
There may be multiple elements with the same name. This is typical with radio buttons and checkboxes.
40
+
ممکن است elementهای زیادی با نام یکسان وجود داشته باشند. این در مورد radio buttonها و checkboxها معمول است.
40
41
41
-
In that case,`form.elements[name]`is a *collection*. For instance:
42
+
در آن صورت،`form.elements[name]`یک *مجموعه*است. برای مثال:
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`.
61
+
این navigation propertyها به tag structure وابستگی ندارند. تمام control elementها، فرقی ندارد چقدر در فرم عمیق باشند، در `form.elements` قابل دسترسی هستند.
61
62
62
63
63
64
````smart header="Fieldsets as \"subforms\""
64
-
A form may have one or many `<fieldset>` elements inside it. They also have `elements` property that lists form controls inside them.
65
+
.را درون خود فهرست میکنند form controls دارند که `elements` property در خودش داشته باشد. آنها همچنین `<fieldset>` elements یک فرم ممکن است یک یا چند
65
66
66
67
For instance:
67
68
@@ -81,22 +82,22 @@ For instance:
81
82
let fieldset = form.elements.userFields;
82
83
alert(fieldset); // HTMLFieldSetElement
83
84
84
-
// we can get the input by name both from the form and from the fieldset
85
+
// .دریافت کنیم fieldset و هم از form را با نام هم از input ما میتوانیم
There's a shorter notation: we can access the element as`form[index/name]`.
93
+
````warn header="نماد کوتاهتر: `form.name`"
94
+
.دسترسی داشته باشیم element به`form[index/name]` کوتاهتر هم وجود دارد: ما میتوانیم با notation یک
94
95
95
-
In other words, instead of`form.elements.login`we can write `form.login`.
96
+
به عبارت دیگر، به جای`form.elements.login`میتوانیم بنویسیم `form.login`.
96
97
97
-
That also works, but there's a minor issue: if we access an element, and then change its `name`, then it is still available under the old name (as well as under the new one).
98
+
آن هم کار میکند، ولی یک مشکل جزئی وجود دارد: اگر به یک element دسترسی داشته باشیم، و بعد `name` آن را تغییر بدهیم، آنگاه آن هنوز با نام قدیمی قابل دسترسی است (همچنین با نام جدید)
0 commit comments