17.13.2 Successful controls
- 詳細內容
- 分類:HTML
- 發佈:2013-08-27, 週二 23:36
- 點擊數:1593
17.13.2 Successful controls:
這篇文章是W3C HTML4.01中的 "successful controls"章節翻譯過來的。
老實說我真的不知道Successful controls要怎麼翻才有意義。所以我就暫時把她稱之為成功控制元素吧,元素是表單元素的意思,像是<input>之類的。
A successful control is "valid" for submission. Every successful control has its control name paired with its current value as part of the submitted form data set. A successful control must be defined within a FORM element and must have a control name.
所謂的成功控制元素(successful control),是可以有效提交的表單元素。每一個成功控制元素都有它自己的控制名稱(control name,由name屬性所指定的),以及與它配對的目前值( current value,此值一開始由初始值設定,也就是value屬性的值,後續可藉由使用者的互動或是腳本語言來修改。 ),組成了一組提交用的表單資料組(form data set,由一連串的 control name/current value 所組成)。成功控制元素必須是定義在FORM
元素中的元素並且必然有其控制名稱(control name)(也就是說會有name屬性)。
However:
- Controls that are disabled cannot be successful.
- If a form contains more than one submit button, only the activated submit button is successful.
- All "on" checkboxes may be successful.
- For radio buttons that share the same value of the name attribute, only the "on" radio button may be successful.
- For menus, the control name is provided by a SELECT element and values are provided by OPTION elements. Only selected options may be successful. When no options are selected, the control is not successful and neither the name nor any values are submitted to the server when the form is submitted.
- The current value of a file select is a list of one or more file names. Upon submission of the form, the contents of each file are submitted with the rest of the form data. The file contents are packaged according to the form's content type.
- The current value of an object control is determined by the object's implementation.
但是:
- 具有 disabled 屬性的表單元素不能是成功的控制元素。
- 假如一個表單內有超過1個提交按鈕,只有被按下的那個提交按鈕會是成功的。
- 所有被選到的checkboxes(多選框,四四方方可以打勾的那種)都是成功的。
- 對於radio buttons(單選框,圓圓的,一組只能選一個的那種,相同的name屬性代表是同一組)而言,name屬性的值若是相等,只有被選到的那一個才會是成功的。
- 對於menus元素而言, 控制名稱(control name)是SELECT元素的name屬性,而值是由OPTION元素提供。只有被選到的OPTION才會是成功的。如果沒有選到任何選項(option),那整個控制元素都不會是成功的,也完全不會被提交到伺服端。
- 檔案選擇(file select)的目前值(current value)是一個或多個檔案名稱列表. 表單被提交後,每個檔案的內容與其餘的表單資料會被提交。檔案的內容會依據表單的內容類型(content type)來包裝。
- 物件控制的目前值是由物件介面所決定。
If a control doesn't have a current value when the form is submitted, user agents are not required to treat it as a successful control.
Furthermore, user agents should not consider the following controls successful:
- Reset buttons.
- OBJECT elements whose declare attribute has been set.
Hidden controls and controls that are not rendered because of style sheet settings may still be successful. For example:
<FORM action="..." method="post"> <P> <INPUT type="password" style="display:none" name="invisible-password" value="mypassword"> </FORM>
will still cause a value to be paired with the name "invisible-password" and submitted with the form.
假如控制元素在被提交時並沒有目前值( current value)。使用者助理(瀏覽器之類的東西)可以將其視為不成功的控制元素。(這裡的意思是瀏覽器可以把它當成成功,也可以當成不成功。)
此外,使用者助理不能把下面的控制元素視為是成功的:
- 重置按鈕
- 具有declare屬性的物件(OBJECT)元素。
不被顯示的隱藏控制元素會因為樣式表設定的關係而可能會是成功的,譬如:
<FORM action="..." method="post"> <P> <INPUT type="password" style="display:none" name="invisible-password" value="mypassword"> </FORM>
依然會產生一個值與name屬性"invisible-password"最為配對,並且提交該表單 。
按個讚!~支持本站!~