Skip to content

Commit 62c52e1

Browse files
until line 100
1 parent 72c62f8 commit 62c52e1

1 file changed

Lines changed: 20 additions & 19 deletions

File tree

2-ui/4-forms-controls/1-form-elements/article.md

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1-
# Form properties و methodها
1+
# Form properties و methods
22

33
فرم‌ها و control elementها مثل `<input>` دارای prperty و eventهای ویژه‌ای هستند.
44

55
وقتی فرم‌ها را یاد بگیریم، کار کردن با آن‌ها بسیار راحت‌تر می‌شود.
66

77
## Navigation: form and elements
88

9-
Document forms are members of the special collection `document.forms`.
9+
فرم‌های document از اعضای مجموعه‌ی ویژه‌ی `document.forms` هستند.
10+
11+
این به اصطلاح یک مجموعه‌ی نام‌گذاری شده است: هم نام‌گذاری شده و هم ترتیب‌دار شده است. برای دسترسی به فرم می‌توانیم هم از نام آن و هم از شماره‌ی آن در document استفاده کنیم.
1012

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.
1213

1314
```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 اولین فرم در
1617
```
1718

18-
When we have a form, then any element is available in the named collection `form.elements`.
19+
وقتی یک فرم داریم،‌ در این صورت هر elementای در مجموعه‌ی نام‌گذاری شده با `form.elements` قابل دسترسی است.
1920

20-
For instance:
21+
برای مثال:
2122

2223
```html run height=40
2324
<form name="my">
@@ -26,19 +27,19 @@ For instance:
2627
</form>
2728

2829
<script>
29-
// get the form
30+
// form گرفتن
3031
let form = document.forms.my; // <form name="my"> element
3132
32-
// get the element
33+
// element گرفتن
3334
let elem = form.elements.one; // <input name="one"> element
3435
3536
alert(elem.value); // 1
3637
</script>
3738
```
3839

39-
There may be multiple elements with the same name. This is typical with radio buttons and checkboxes.
40+
ممکن است elementهای زیادی با نام یکسان وجود داشته باشند. این در مورد radio buttonها و checkboxها معمول است.
4041

41-
In that case, `form.elements[name]` is a *collection*. For instance:
42+
در آن صورت، `form.elements[name]` یک *مجموعه*‌است. برای مثال:‌
4243

4344
```html run height=40
4445
<form>
@@ -57,11 +58,11 @@ alert(ageElems[0]); // [object HTMLInputElement]
5758
</script>
5859
```
5960

60-
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` قابل دسترسی هستند.
6162

6263

6364
````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 یک فرم ممکن است یک یا چند
6566
6667
For instance:
6768
@@ -81,22 +82,22 @@ For instance:
8182
let fieldset = form.elements.userFields;
8283
alert(fieldset); // HTMLFieldSetElement
8384
84-
// we can get the input by name both from the form and from the fieldset
85+
// .دریافت کنیم fieldset و هم از form را با نام هم از input ما می‌توانیم
8586
alert(fieldset.elements.login == form.elements.login); // true
8687
*/!*
8788
</script>
8889
</body>
8990
```
9091
````
9192

92-
````warn header="Shorter notation: `form.name`"
93-
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 یک
9495

95-
In other words, instead of `form.elements.login` we can write `form.login`.
96+
به عبارت دیگر، به جای `form.elements.login` می‌توانیم بنویسیم `form.login`.
9697

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` آن را تغییر بدهیم، آنگاه آن هنوز با نام قدیمی قابل دسترسی است (همچنین با نام جدید)
9899

99-
That's easy to see in an example:
100+
آسان‌تر است که آن را در یک مثال ببینیم:
100101

101102
```html run height=40
102103
<form id="form">

0 commit comments

Comments
 (0)