EasyUI 表单赋值

前言

使用easyui进行功能的开发,经常会用到表单,以下对表单赋值进行总结。

textbox 文本框赋值

代码如下:

//文本框
<input type="text" class="easyui-textbox" name="txt1" id="txt1" />
//给文本框赋值
$("#txt1").textbox('setValue', '我是文本框');

combobox 组合框赋值

代码如下:

//下拉框
<select class="easyui-combobox" data-options="editable:false,panelHeight:'auto',130" name="com1" id="com1" ></select>
//给下拉框赋值
$("#com1").combobox('setValue', '下拉框值1');

datebox 日期框赋值

代码如下:

//日期框
<input type="text" class="easyui-datebox" name="datebox1" id="datebox1"/>
//给日期框赋值
$("#datebox1").datebox('setValue', '时间');

Datetimebox 日期时间框

代码如下:

//日期时间框
<input type="text" class="easyui-datetimebox" name="datetimebox1" id="datetimebox1"/>
//给日期文本框赋值
 $('#datetimebox1').datetimebox({
  value: '时间值',
  showSeconds: false //定义是否显示秒的信息
});

radiobutton 单选赋值

代码如下:

//单选
<label for="sfbt" class="lab">是否必填:</label>
<input type="radio" class="easyui-validatebox" name="sfbt"  value="是" /><label>是</label>
<input type="radio" class="easyui-validatebox" name="sfbt"  value="否" /><label>否</label>
//給单选赋值
if (rows[0].isrequired == true) {
  $("input[name='sfbt'][value='是']").prop("checked", true);
} else {
  $("input[name='sfbt'][value='否']").prop("checked", true);
}

numberbox 数字框赋值

代码如下:

//数字框
<input type="text" class="easyui-numberbox ins" name="zs" id="zs" data-options="min:0,precision:0"/>
//给数字框赋值
$("#zs").numberbox('setValue', 1);

min:0 --最小值
precision:0 --需要显示的小数位

Validatebox 验证框赋值

代码如下:

//验证框
<input id="validatebox1" class="easyui-validatebox" data-options="required:true,validType:'email'">
//验证框赋值
$("#validatebox1").validatebox('setValue', '123456@qq.com');

passwordbox 密码框赋值

代码如下:

//密码框
<input id="passwordbox1" class="easyui-passwordbox" prompt="Password" iconWidth="28" />
//密码框赋值
$("#passwordbox1").passwordbox('setValue', '123456');
原文地址:https://www.cnblogs.com/ZengJiaLin/p/15179123.html