0

我需要将 ID 添加到列表框中的复选框

<input type=”checkbox” name=”vehicle” id = 1>Code</br>
<input type=”checkbox” name=”vehicle” id = 2>Select

一旦我选择了 CheckBox,我需要获取 CheckBox Id,我也可以勾选 CheckBox Based on ID 怎么办??????

但这里不能添加

var source = [
"Affogato",
"Caffé Latte"];

// Create a jqxListBox
$(“#jqxListBox”).jqxListBox({
source: source,
theme: ‘energyblue’,
width: ’200px’,
height: ’250px’,
checkboxes:true
});
4

1 回答 1

1

http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxlistbox/index.htm?(arctic)#demos/jqxlistbox/checkboxes.htm

您可以使用该checkChange事件,在您的情况下,源应该有两个值(1 - displayMember,2 - valueMember):

var source = [{
  vehicle: "Affogato",
  id: 122
}, {
  vehicle: "Americano",
  id: 156
}, {
  vehicle: "Bicerin",
  id: 1023
}, {
  vehicle: "Breve",
  id: 4567
}];

$("#jqxListBox").jqxListBox({
  source: source,
  displayMember: "vehicle", 
  valueMember: "id",
  checkboxes: true
});

$("#jqxListBox").on('checkChange', function (event) {
  var args = event.args;
  // get new check state.
  var checked = args.checked;
  // get the item and it's label and value fields.
  var item = args.item;
  var itemLabel = item.label;
  var itemValue = item.value;
});

试试这个来帮助:https ://jsfiddle.net/charlesrv/YnqPP/31/

于 2015-05-17T03:26:27.640 回答