jQWidgets Forums

jQuery UI Widgets Forums Lists ComboBox ComboBox Key Value As Html Select tag

This topic contains 2 replies, has 2 voices, and was last updated by  Dimitri 13 years, 2 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • ComboBox Key Value As Html Select tag #1805

    Dimitri
    Member

    Hi ,

    Im trying to get the similar way to work with a jqCombobox as a HTML select tag.

    I ‘m juste asking the way to get some thing like <select><option value=$id>$name</option> with a jqCombox box.

    For example :

    In order to  populate a listBox according to the selected value id (not index) of the selected item

    Thanks for watching,

    ComboBox Key Value As Html Select tag #1821

    support
    Participant

    Hi Dimitri,

    You can define the ComboBox’s source by setting its value and label members. The label member represents the display string.

    Here’s how to bind the ComboBox and create its source object:

                 var source = [
    {value: "key1", label: "Label1"},
    {value: "key2", label: "Label2"},
    {value: "key3", label: "Label3"},
    {value: "key4", label: "Label4"},
    ];
    // Create a jqxComboBox
    $("#jqxComboBox").jqxComboBox({ source: source, width: '200px', height: '25px'});

    Then to get the selected value, you can bind to the ‘select’ event and call the ‘getitem’ method. The method retrieves a ComboBox item that has value and label properties.

    For example:

                   $('#jqxComboBox').bind('select', function (event) {
    var args = event.args;
    var item = $('#jqxComboBox').jqxComboBox('getItem', args.index);
    // get value.
    var value = item.value;
    // get label.
    var label = item.label;
    });

    Best Regards,
    Ivan Penev

    jQWidgets Team
    http://www.jqwidgets.com

    ComboBox Key Value As Html Select tag #1823

    Dimitri
    Member

    Thanks for that great help, that’s really what I needed.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.