如有下ligerform表单:
var formData = [ { display: "区域", name: "QYYJ", newline: true, labelWidth: 100, width: 220, space: 2, type: "select", comboboxName: "QYYJName", options: { valueFieldID: "QYYJ" }, group: "区域位置及周边环境", groupicon: "@Url.Content("~/Content/icons/32X32/import.png")" }, { display: "", name: "QYEJ", newline: false, labelWidth: 2, width: 220, space: 0, type: "select", comboboxName: "QYEJName", options: { valueFieldID: "QYEJ" } }, { display: "区域描述", name: "QYMS", newline: true, labelWidth: 100, width: 700, space: 50, type: "textarea"}, { display: "周边环境", name: "ZBHJ", newline: true, labelWidth: 100, width: 700, space: 50, type: "textarea" }, { display: "估价方法", name: "GJFFs", newline: true, labelWidth: 100, width: 220, space: 50, type: "select", group: "估价法及其概念", groupicon: "@Url.Content("~/Content/icons/32X32/communication.gif")", comboboxName: "GJFFsName", options: { valueFieldID: "GJFFs", isMultiSelect: true, split: ‘,‘ } }, { display: "估价法概念", name: "GJFFGN", newline: true, labelWidth: 100, width: 700, space: 50, type: "textarea" }, { display: "房屋用途", name: "FWYTQZ", newline: true, labelWidth: 100, width: 220, space: 50, type: "select", comboboxName: "FWYTQZName", options: { valueFieldID: "FWYTQZ" }, group: "房屋用途及其物权法规定", groupicon: "@Url.Content("~/Content/icons/32X32/bank.gif")" }, { display: "物权法规定", name: "WQFGD", newline: true, labelWidth: 100, width: 700, space: 50, type: "textarea" }] //创建表单结构 var mainform = $("#mainform"); mainform.ligerForm({ inputWidth: 280, fields: formData, toJSON: JSON2.stringify })
如要对其中的控件进行赋值与取值,网上搜了好多种方法都不可行(为了不混淆视听,就不列举那些错误的例子了),下面是亲测正确的方法:
一、针对下拉框select的取值与赋值:
(1)取值: 获取value值: $("[name=QYYJ]").val(), //注意name是select的名称 获取text值: $("[name=QYYJName]").val() //注意name是combobox的名称 //或者 $("[#QYYJName]").val(), (2)赋值: 用liger.get("QYYJName").setData(值);//注意name是combobox的名称
二、针对text/textarea的取值与赋值:
取值:$("[name=GJFFGN]").val() 赋值:用 $("#text的name").attr("value",值)
时间: 2024-11-14 04:28:34