Field Plug-in

授权协议 未知
开发语言
所属分类 jQuery 插件、 其他jQuery插件
软件类型 开源软件
地区 不详
投 递 者 禄星腾
操作系统 未知
开源组织
适用人群 未知
 软件概览

This plugin greatly expands the ability to retrieve and set values in forms beyond jQuery's standard val() method (and Mike Alsup's Form Plug-in's fieldArray() method) by allowing you to interact with all types of form field elements (except input[@type="file"], which is a read-only element.) It works the same way for text elements as it does for radio, checkbox and select elements.

The plug-in was built on the concept that you want to manipulate the fields like their traditional variables. Selectors should be written to query a specific field object (i.e. elements that would be linked together via a common name attribute, for example $("input[@name='myRadioButton']").)

Elements that return multiple values are either separated by a comma or returned as an array based on which methods you invoke.

For elements that allow more than one option to be select (select and checkbox elements) you can specify a comma delimited list or an array of values to mark multiple options as being selected.

Syntax Examples

  • $("input[@name='users']").fieldArray();
    Returns an array of all values selected or entered for the selector. If the selector was a checkbox or select element, the array would contain the value of each item selected/checked.
  • $("input[@name='users']").fieldArray(["dan", "joern", "karl", "john"]);
    Sets the value of the field to "dan,joern,karl,john". If the selector was a checkbox or select element, then the options with the values of "dan", "joern", "karl" and "john" would be selected--all other options would be unselected.
  • $("input[@name='users']").getValue();
    Returns a comma delimited string of all values selected or entered for the selector. If the selector was a checkbox or select element, the string would contain the value of each item selected/checked as a separate item in the list.
  • $("input[@name='users']").setValue("dan,joern,karl,john");
    Sets the value of the field to "dan,joern,karl,john". If the selector was a checkbox or select element, then the options with the values of "dan", "joern", "karl" and "john" would be selected--all other options would be unselected.
  • $("#formName").formHash();
    Returns a hash map of all the form fields and their values.
  • $("#formName").formHash({"name": "Dan G. Switzer, II", "state": "OH"});
    Returns the jQuery chain and sets the fields "name" and "state" with the values "Dan G. Switzer, II" and "OH" respectively.
  • $("input:checkbox").limitSelection(3);
    $("input:checkbox").limitSelection({limit: 3});
    Limits the user from being able to select more than 3 items in a checkbox/select element. Once the user selects more than 3 items, an error alert() message is displayed.
  • $("input:checkbox").limitSelection(3, {onsuccess: successCallback, onfailure: errorCallback});
    $("input:checkbox").limitSelection({limit: 3, onsuccess: successCallback, onfailure: errorCallback});
    Limits the user from being able to select more than 3 items in a checkbox/select element. If 3 items or less are selected, the successCallback is executed. If more than 3 items is selected, the errorCallback is executed.
  • $("input:checkbox").createCheckboxRange();
    The createCheckboxRange() allows you to create a Gmail-like checkbox range selector. By clicking on a checkbox element and then [SHIFT] clicking on an additional checkbox element, the entire range of checkbox elements between the first and second elements clicked with be checked or unchecked (based upon the status of the first checkbox clicked.)
  • $("input:checkbox").createCheckboxRange(callback);
    Triggers the callback function to run each time the checked status of a field changes. This allows you to attach behaviors--such as highlighting the checkbox's row. This callback function's "this" reference is to the jQuery object who's status was changed. An single argument is passed that's a boolean indicating whether or not the field is checked or not.
  • $("#formName").autoAdvance();*
    The autoAdvance() will search through the matching elements in the selector for any text-based input fields. It will then apply an onkeyup event that will take the user to the next field in the tabIndex (within the context of the form) when the maxlength value of the field has been reached.
  • $("#formName").autoAdvance(callback);*
    Automatic advances to next field and triggers the callback function on the field the user left. This callback function's "this" reference is to the jQuery object who's field your leaving. An single argument is passed that's a reference to the field that's being moved to.
  • $("input[@name='users']").moveNext();*
    This would move the focus to the next field in the tabIndex array from the "users" field. If the next tabItem is outside of the form's context, the first element in the form will be selected.
  • $("input[@name='users']").movePrev();*
    This would move the focus to the previous field in the tabIndex array from the "users" field. If the previous tabItem is outside of the form's context, the last element in the form will be selected.
  • $("input[@name='users']").moveIndex(3);*
    This would move the focus to the third element in the tabIndex array. If the value "3" is outside the tabIndex array for the current form, then the last field would be selected.
  • $("input[@name='users']").getTabIndex();*
    This returns the tabIndex for the current field as it relates to the parent
    form object.

* The tabIndex navigation methods attempt to follow the spec for tabbing through elements. This means that elements that have a specified tabIndex take priority over elements that do not specify an index. Disabled items are skipped altogether. The major exception is that the methods will only move within the parent form object.

 相关资料
  • 本文向大家介绍从发展历程、产品机制、运营机制、发展瓶颈等方面对2-3个产品进行比较。备选的有头条系的抖音、火山,快手、小红书、微博、朋友圈、B站、Ins等等。相关面试题,主要包含被问及从发展历程、产品机制、运营机制、发展瓶颈等方面对2-3个产品进行比较。备选的有头条系的抖音、火山,快手、小红书、微博、朋友圈、B站、Ins等等。时的应答技巧和注意事项,需要的朋友参考一下 抖音vs快手 从发展历程、产

  • 本文向大家介绍jQuery.fn的init方法返回的this指的是什么对象?为什么要返回this?相关面试题,主要包含被问及jQuery.fn的init方法返回的this指的是什么对象?为什么要返回this?时的应答技巧和注意事项,需要的朋友参考一下 [jQuery] jQuery.fn的init方法返回的this指的是什么对象?为什么要返回this?

  • 问题内容: 我有桌子 我还有一张桌子 我要插入两个远程怪物:一个被称为 “弓箭妖精” ,攻击距离为 10 ,另一个被称为 “龙” ,攻击距离为 50 。我怎样才能在一条指令中做到这一点? 到目前为止,我已经尝试过了: 最坏的方法 这很不好,因为name列允许重复,并且检索到的记录可能不止一次。。。也不得不两次写出怪物的名字似乎不是一个好习惯。 插入…返回 如果表仅具有的列(外键),那么我可以使用以

  • 问题内容: 我必须在表target_table中插入/更新一些记录。这些记录是一个source_table。 我正在使用MERGE更新/插入target_table。 我想在更新中添加一些特定条件。 那么就应该只有更新,否则就没有更新或插入。 问题答案: 您可以简单地在中添加子句。在oracle docs中有更多关于它的信息。 因此,在您的情况下,它应如下所示:

  • 问题内容: 对于这样的表: 什么是正确的一次查询插入以下操作: 给定用户,插入新记录并返回新记录。但是,如果已经存在,则只需返回。 我知道PostgreSQL 9.5中针对的新语法,但是鉴于我需要返回,因此我无法弄清楚它是否有帮助(如果有的话)。 似乎和不属于在一起。 问题答案: UPSERT的实现非常复杂,以确保不会发生并发写访问。看一下这个Postgres Wiki ,它在最初的开发过程中用作

  • 问题内容: 我的Maven POM文件遇到问题,无法找到火花依赖关系,并返回错误:无法读取org.apache.spark:spark-streaming- kafka_2.10:jar:1.2.1的工件描述符 我已经确认这对任何公司防火墙都不是问题,因为其他所有依赖项都已正确加载,仅此一项。 我还能够在我的Maven设置中确认它正在尝试从以下存储库中提取。我尝试删除本地计算机上的.m2存储库以重

  • 问题内容: 我正在将一个应用程序从IntelliJ IDEA部署到本地Tomcat服务器。我以为您部署的应用程序放置在文件夹中,但是并没有出现在该文件夹中。 这样对吗?它在哪里? 问题答案: 是的,如果您使用的是IntelliJ IDEA,则该应用程序不会在Tomcat 目录中打开。您的工件在目录中,例如: 这是IntelliJ创建的默认目录。 Tomcat配置位于其他文件夹中。我正在使用Wind

  • 问题内容: 我知道,当我阅读答案时,会发现我已经忽略了我眼中的事物。但是我花了最后30分钟试图自己弄清楚,但没有结果。 因此,我正在用Java 6编写程序,并发现了一些(对我而言)奇怪的功能。为了尝试隔离它,我举了两个小例子。我首先尝试了以下方法: 编译器拒绝了它:类型不匹配:无法从null转换为int。 这对我来说很好,并且尊重我熟悉的Java语义。然后我尝试了以下方法: 编译没有错误!但是,我