Jquery給easyui的表單元素賦值,獲取值總結


1.Input

  a. validatebox

  定義:

   <input type="text" name="APPLYDEPTNAME" id="APPLYDEPTNAME" style="width: 99%"
                      maxlength="50" class="easyui-validatebox" data-options="required:true" />

  賦值:

$("#APPLYDEPTNAME").val('1212'),

  取值:

$("#APPLYDEPTNAME").val()

 b.ComboBox

定義:

 <td colspan="5">
                    城市:
                    <input id="city" style="width: 80px" class="easyui-combobox" data-options=" valueField: 'CityAreaCode', textField: 'CityAreaName', url: '../../Ajax/InforService.ashx?Method=GetCity',  
                          
                         onSelect: function(rec){  
                         var url = '../../Ajax/InforService.ashx?Method=GetArea&CityAreaCode='+rec.CityAreaCode;  
  
                         $('#area').combobox('reload', url);
                         $('#area').combobox('setValues', '');

                          }" />
                    區縣:
                    <input id="area" class="easyui-combobox" data-options="valueField:'CityAreaCode',textField:'CityAreaName'" />
                    街道:
                    <input type="text" value="" onchange="doValue(this.value)" style="width: 45%" name="SC001_APPLYDEPTADDRESS"
                        maxlength="23" class="easyui-validatebox" id="SC001_APPLYDEPTADDRESS" data-options="required:true" />

  取值:

 $("#city2").combobox("getValues")
 $("#city").combobox("getValues") + "," + $("#area").combobox("getValues") + "," + $("#SC001_APPLYDEPTADDRESS").val(),

  賦值:

 $('#city').combobox('setValue', ‘北京’);

回顯:
//公司地址
var str4 = result.APPLYDEPTADDRESS;
if (str4 != null) {
var strs4 = new Array();
strs4 = str4.split(",");
$('#city').combobox('setValue', strs4[0]);
var url = '../../Ajax/InforService.ashx?Method=GetArea&CityAreaCode=' + strs4[0];
$('#area').combobox('reload', url);
$('#area').combobox('setValue', strs4[1]);
$("#APPLYDEPTADDRESS").val(strs4[2]);
}

還有這種寫法:   <input class="easyui-combobox" id="maxAge" name="maxAge" style="width:100px" data-options="valueField:'value',textField:'lable',data:[{
                            lable:'不限',
                            value:'-1',
                            selected:true
                            },
                            {
                            lable:'1',
                            value:'1'
                            },
                            {
                            lable:'10',
                            value:'10'
                            },
                            {
                            lable:'20',
                            value:'20'
                            },
                            {
                            lable:'30',
                            value:'30'
                            },
                            {
                            lable:'40',
                            value:'40'
                            },
                            {
                            lable:'50',
                            value:'50'
                            },
                            {
                            lable:'60',
                            value:'60'
                            },
                            {
                            lable:'70',
                            value:'70'
                            },
                            {
                            lable:'80',
                            value:'80'
                            },
                            {
                            lable:'90',
                            value:'90'
                            },
                             {
                            lable:'100',
                            value:'100'
                            }
                            ,
                             {
                            lable:'200',
                            value:'200'
                            }
                             ,
                             {
                            lable:'300',
                            value:'300'
                            }
                            ]"/>

  

 

c.NumberBox

定義:

<input type="text" class="easyui-numberbox" maxlength="20" name="nn" id="nn" />

賦值:

$('#nn').numberbox('setValue', 206.12);

取值:

var v = $('#nn').numberbox('getValue');


d.DateBox

 

定義:

 <input type="text" name="nn" id="nn" class="easyui-datebox"
                        data-options="formatter:myDate.InitDateBox.formatter,parser:myDate.InitDateBox. parser" />

賦值:

 $("#SC001_CERTIFICATEVALID").datebox('setValue', '2014-9-12');

取值:

 $('#nn').datebox('getValue'),

e.NumberSpinner 

定義:
<input id="ss" class="easyui-numberspinner" style="width:80px;"  
        required="required" data-options="min:10,max:100,editable:false">  
賦值:
$('#ss').numberspinner('setValue', 8234725);  
取值:
var v = $('#ss').numberspinner('getValue');  

f.menubutton

定義:

 <a href="javascript:void(0)" id="mb" name="mb" disabled="true" class="easyui-menubutton"   
              data-options="menu:'#mm',iconCls:'icon-edit' ">確認</a>  
              <div id="mm" name="mm"style="width:150px;">  
              <div data-options="iconCls:'icon-undo'" onclick="initTool.Check('確認通過')">確認通過</div>  
              <div data-options="iconCls:'icon-redo'" onclick="initTool.Check('確認不通過')">確認不通過</div>
              </div>

 

另附單選按鈕Radio

定義

 <td height="30" colspan="5">
                    <input type="radio" name="APPLYDEPTTYPE" value="事業法人" checked="checked" />事業法人
                    <input type="radio" name="APPLYDEPTTYPE" value="企業法人" />企業法人
                    <input type="radio" name="APPLYDEPTTYPE" value="社團法人" />社團法人
                    <input type="radio" name="APPLYDEPTTYPE" value="其他" />其他
                </td>

賦值:

 var str = result.APPLYDEPTTYPE;
 $("[value='" + str + "']").attr("checked", true);

取值:

$('input[name="APPLYDEPTTYPE"]:checked').val()

另附多選框checkbox

定義:

 <td height="60" colspan="5">
                    &nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
                    <input type="checkbox" name="BUSINESSSCOPE" value="" />水 &nbsp&nbsp&nbsp&nbsp
                    &nbsp&nbsp&nbsp&nbsp
                    <input type="checkbox" name="BUSINESSSCOPE" value="空氣" />空氣 &nbsp&nbsp&nbsp&nbsp
                    &nbsp&nbsp&nbsp&nbsp
                    <input type="checkbox" name="BUSINESSSCOPE" value="土壤" />土壤</br>
                    &nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
                    <input type="checkbox" name="BUSINESSSCOPE" value="噪聲" />
                    噪聲 &nbsp&nbsp&nbsp&nbsp &nbsp&nbsp&nbsp&nbsp
                    <input type="checkbox" name="BUSINESSSCOPE" value="生物" />生物
                </td>

 

賦值:

  var str3 = result.BUSINESSSCOPE;
                    if (str3 != null) {
                        var strs = new Array();

                        strs = str3.split(",");
                        for (i = 0; i < strs.length; i++)
                        { $("[value='" + strs[i] + "']").attr("checked", true) };
                    }

取值:

 var isc = "";
                $("input[name='BUSINESSSCOPE']:checked").each(function () { //遍歷table里的全部checkbox
                    isc += $(this).val() + ","; //獲取被選中的值
                });

                if (isc.length > 0) //如果獲取到
                    isc = isc.substring(0, isc.length - 1); //把最后一個逗號去掉
string isc就是值

 

2.TextArea

  定義:

  <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>

賦值和取值與Input標簽相同。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM