[JavaScript] Jquery给easyui的表单元素赋值,获取值总结 →→→→→进入此内容的聊天室

来自 , 2021-02-04, 写在 JavaScript, 查看 110 次.
URL http://www.code666.cn/view/91f9fec9
  1. -
  2. 时间 2014-09-16 10:57:35  博客园-所有随笔区
  3. 原文  http://www.cnblogs.com/szxlh/p/3973273.html
  4. 1.Input
  5.  
  6. a. validatebox
  7.  
  8. 定义:
  9.  
  10. <input type="text" name="APPLYDEPTNAME" id="APPLYDEPTNAME" style="width: 99%"
  11.                       maxlength="50" class="easyui-validatebox" data-options="required:true" />
  12. 赋值:
  13.  
  14. $("#APPLYDEPTNAME").val('1212'),
  15. 取值:
  16.  
  17. $("#APPLYDEPTNAME").val()
  18. b. ComboBox
  19.  
  20. 定义:
  21.  
  22. <td colspan="5">
  23.   城市:
  24.   <input id="city" style="width: 80px" class="easyui-combobox" data-options=" valueField: 'CityAreaCode', textField: 'CityAreaName', url: '../../Ajax/InforService.ashx?Method=GetCity',  
  25.        
  26.       onSelect: function(rec){  
  27.       var url = '../../Ajax/InforService.ashx?Method=GetArea&CityAreaCode='+rec.CityAreaCode;  
  28.  
  29.       $('#area').combobox('reload', url);
  30.       $('#area').combobox('setValues', '');
  31.  
  32.        }" />
  33.   区县:
  34.   <input id="area" class="easyui-combobox" data-options="valueField:'CityAreaCode',textField:'CityAreaName'" />
  35.   街道:
  36.   <input type="text" value="" onchange="doValue(this.value)" style="width: 45%" name="SC001_APPLYDEPTADDRESS"
  37.       maxlength="23" class="easyui-validatebox" id="SC001_APPLYDEPTADDRESS" data-options="required:true" />
  38. 取值:
  39.  
  40. $("#city2").combobox("getValues")
  41.  $("#city").combobox("getValues") + "," + $("#area").combobox("getValues") + "," + $("#SC001_APPLYDEPTADDRESS").val(),
  42. 赋值:
  43.  
  44. $('#city').combobox('setValue', ‘北京’);
  45. 回显:
  46.  
  47. //公司地址
  48.  
  49. var str4 = result.APPLYDEPTADDRESS;
  50.  
  51. if (str4 != null) {
  52.  
  53. var strs4 = new Array();
  54.  
  55. strs4 = str4.split(",");
  56.  
  57. $('#city').combobox('setValue', strs4[0]);
  58.  
  59. var url = '../../Ajax/InforService.ashx?Method=GetArea&CityAreaCode=' + strs4[0];
  60.  
  61. $('#area').combobox('reload', url);
  62.  
  63. $('#area').combobox('setValue', strs4[1]);
  64.  
  65. $("#APPLYDEPTADDRESS").val(strs4[2]);
  66.  
  67. }
  68.  
  69. c. NumberBox
  70.  
  71. 定义:
  72.  
  73. <input type="text" class="easyui-numberbox" maxlength="20" name="nn" id="nn" />
  74. 赋值:
  75.  
  76. $('#nn').numberbox('setValue', 206.12);
  77. 取值:
  78.  
  79. var v = $('#nn').numberbox('getValue');
  80.  
  81.  
  82. d.DateBox
  83. 定义:
  84.  
  85. <input type="text" name="nn" id="nn" class="easyui-datebox"
  86.                         data-options="formatter:myDate.InitDateBox.formatter,parser:myDate.InitDateBox. parser" />
  87. 赋值:
  88.  
  89. $("#SC001_CERTIFICATEVALID").datebox('setValue', '2014-9-12');
  90. 取值:
  91.  
  92. $('#nn').datebox('getValue'),
  93. e.NumberSpinner
  94.  
  95. 定义:
  96. <input id="ss" class="easyui-numberspinner" style="width:80px;"  
  97.         required="required" data-options="min:10,max:100,editable:false">
  98. 赋值:
  99. $('#ss').numberspinner('setValue', 8234725);
  100. 取值:
  101. var v = $('#ss').numberspinner('getValue');
  102. 另附 单选按钮Radio
  103.  
  104. 定义
  105.  
  106. <td height="30" colspan="5">
  107.                     <input type="radio" name="APPLYDEPTTYPE" value="事业法人" checked="checked" />事业法人
  108.                     <input type="radio" name="APPLYDEPTTYPE" value="企业法人" />企业法人
  109.                     <input type="radio" name="APPLYDEPTTYPE" value="社团法人" />社团法人
  110.                     <input type="radio" name="APPLYDEPTTYPE" value="其他" />其他
  111.                 </td>
  112. 赋值:
  113.  
  114. var str = result.APPLYDEPTTYPE;
  115.  $("[value='" + str + "']").attr("checked", true);
  116. 取值:
  117.  
  118. $('input[name="APPLYDEPTTYPE"]:checked').val()
  119. 另附 多选框checkbox
  120.  
  121. 定义:
  122.  
  123. <td height="60" colspan="5">
  124.           &nbsp
  125.   <input type="checkbox" name="BUSINESSSCOPE" value="水" />水    &nbsp
  126.      &nbsp
  127.   <input type="checkbox" name="BUSINESSSCOPE" value="空气" />空气    &nbsp
  128.      &nbsp
  129.   <input type="checkbox" name="BUSINESSSCOPE" value="土壤" />土壤</br>
  130.           &nbsp
  131.   <input type="checkbox" name="BUSINESSSCOPE" value="噪声" />
  132.   噪声         &nbsp
  133.   <input type="checkbox" name="BUSINESSSCOPE" value="生物" />生物
  134.                 </td>
  135. 赋值:
  136.  
  137. var str3 = result.BUSINESSSCOPE;
  138.                     if (str3 != null) {
  139.   var strs = new Array();
  140.  
  141.   strs = str3.split(",");
  142.   for (i = 0; i < strs.length; i++)
  143.   { $("[value='" + strs[i] + "']").attr("checked", true) };
  144.                     }
  145. 取值:
  146.  
  147. var isc = "";
  148.         $("input[name='BUSINESSSCOPE']:checked").each(function () { //遍历table里的全部checkbox
  149.           isc += $(this).val() + ","; //获取被选中的值
  150.         });
  151.  
  152.         if (isc.length > 0) //如果获取到
  153.           isc = isc.substring(0, isc.length - 1); //把最后一个逗号去掉
  154. string isc就是值
  155. 2.TextArea
  156.  
  157. 定义:
  158.  
  159. <textarea cols="25" rows="3" name="BUSINESSALLOW" id="BUSINESSALLOW" onpropertychange="if(this.value.length>100){this.value=this.value.substr(0,100)}" class="easyui-validatebox" style="width: 99%; height: 99%" data-options="required:true"></textarea>
  160. 赋值和取值与Input标签相同。

回复 "Jquery给easyui的表单元素赋值,获取值总结"

这儿你可以回复上面这条便签

赋值和取值与Input标签相同。
captcha