The value and assignment _jquery of the combo box of Easyui

Source: Internet
Author: User
Tags trim

Recently because of work needs, users click the Drop-down box can try the effect of multiple selection, the effect is roughly the following figure:

The implementation code is as follows:

<select id= "Iweekday" class= "col-sm-4 form-control" "Easyui-combobox" state "Name=" data-options=, Multiline:true "style=" width:350px;height:35px ">
<option value=" 1 ">1</option>
<option Value= "2" >2</option> 
<option value= "3" >3</option> 
<option value= "4" >4</ option> 
<option value= "5" >5</option> 
<option value= "6" >6</option> 
< Option value= "7" >7</option> 
</select>

The most important is: Multiple:true means that the dropdown box can be selected, if the single selection: Multiple:false single

Below is a summary of the value and assignment of the ComboBox

2. Assigning value

(1) Single-selection assignment SetValue

$ (' #Id '). ComboBox (' SetValue ', ' key ')

(2) Multiple-selection assignment setvalues

The multiple-selection key value is an array of $ (' #Id '). ComboBox (' Setvalues ', ' Key1,key2,key3 '. Split (', '))

Note: ' Key1,key2,key3 '. Split (', ') cuts the string into an array because the second argument to ComboBox is an array

3. Take the value

(1) Single selection value GetValue

$ (' #Id '). ComboBox (' GetValue ')

(2) Multi-selection value GetValues

The multiple-selection key value is an array, $ (' #Id '). ComboBox (' GetValues ')

Note: The value obtained is an array, and if you want to convert to a comma-delimited string, such as ("1,2,3"), use the Join method, the code is as follows:

var str=$ (' #Id '). ComboBox (' GetValues '). Join (",");

PS: Below see the complete code of Easyui Selectbox assignment value

Assignment value

//Redefine banner var storename_value = ' @ViewBag. Storename '; var department_value =
' @ViewBag. Department ';
var changedate_value = ' @ViewBag. ChangeDate '; 
$ (' #StoreName option:selected '). Text (Storename_value);
$ (' #Department option:selected '). Text (Department_value);
$ (' #StoreName '). ComboBox (' SetValue ', storename_value);
$ (' #Department '). ComboBox (' SetValue ', department_value); 
Bind searchbtn $ (' #this_submit '). Bind (' click ', function () {//var St = $ (' #StoreName option:selected '). Text (). Trim ();
var dep = $ (' #Department option:selected '). Text (). Trim ();
var st = $ (' #StoreName '). ComboBox (' GetValue ');
var dep = $ (' #Department '). ComboBox (' GetValue ');
var changedate = $ (' #datepicker '). Val (); var href = '..
/';
href + + ' &storename= ' + st + ' &department= ' + dep + ' &changedate= ' + changedate;
href = ' &page=1&size=8 ';
window.location.href = href; 
});

The above is a small set to introduce the Easyui combo box values and assignments, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.