📜  Prototype-表单管理

📅  最后修改于: 2020-10-21 08:47:24             🧑  作者: Mango


 

Prototype提供了一种管理HTML表单的简便方法。原型的Form是一个名称空间和一个所有与表单相关的事物的模块,其中包含表单操作和序列化的优点。

它拥有处理整个表单的方法,而其子模块Form.Element处理特定的表单控件。

这是与Form Element相关的所有方法的完整列表。

Prototype表格方法

注意-确保您至少具有1.6版的prototype.js。

S.No. Method & Description
1. disable()

Disables the form as whole. Form controls will be visible but uneditable.

2. enable()

Enables a fully or partially disabled form.

3. findFirstElement()

Finds first non-hidden, non-disabled form control.

4. focusFirstElement()

Gives keyboard focus to the first element of the form.

5. getElements()

Returns a collection of all form controls within a form.

6. getInputs()

Returns a collection of all INPUT elements in a form. Use optional type and name arguments to restrict the search on these attributes.

7. request()

A convenience method for serializing and submitting the form via an Ajax.Request to the URL of the form’s action attribute. The options parameter is passed to the Ajax.Request instance, allowing to override the HTTP method and to specify additional parameters.

8. reset()

Resets a form to its default values.

9. serialize()

Serialize form data to a string suitable for Ajax requests (default behavior) or, if optional getHash evaluates to true, an object hash where keys are form control names and values are data.

10. serializeElements()

Serialize an array of form elements to a string suitable for Ajax requests (default behavior) or, if optional getHash evaluates to true, an object hash where keys are form control names and values are data.