jQWidgets Forums

Forum Replies Created

Viewing 1 post (of 1 total)
  • Author
    Posts
  • in reply to: jqwidgets listbox in Joomla jqwidgets listbox in Joomla #9842

    mephjl
    Member

    ok, but this is the solution without queries in database.

    the first table contains nations
    the second table contains leagues
    the third table contains soccer teams

    this is the code for the first table

    $db =& JFactory::getDBO();
    $query = "SELECT * FROM #__sco_nazioni ORDER BY Nazioni ASC";
    $db->setQuery( $query );
    $nazionis = $db->loadObjectList();
    $numnaz = count($nazionis);
    for ($i=1; $i<$numnaz;$i++) {
    $nazioni = $nazionis[$i];
    if ($i == 1) {
    $naz = $nazioni->Nazioni;
    } else {
    $naz .= ",".$nazioni->Nazioni;
    }
    }
    $naz = explode(",",$naz);
    array_unshift($naz,"TUTTE");
    ?>
    <div id="content">
    <script type="text/javascript">
    $(document).ready(function () {
    var theme = getTheme();
    var source = <?php echo json_encode($naz);?>;
    // Create a jqxListBox
    $("#listbox").jqxListBox({ source: source, checkboxes: true, width: 200, height: 250, theme: theme });
    // Check several items.
    // $("#listbox").jqxListBox('checkIndex', 0);
    $("#listbox").bind('checkChange', function (event) {
    var args = event.args;
    if (args.checked) {
    $("#Events").html("Hai selezionato : " + args.label);
    }
    else {
    $("#Events").html("Hai deselezionato : " + args.label);
    }
    var items = $("#listbox").jqxListBox('getCheckedItems');
    var checkedItems = "";
    $.each(items, function (index) {
    if (index < items.length - 1) {
    checkedItems += this.label + ",";
    }
    else checkedItems += this.label;
    });
    $("#CheckedItems").text(checkedItems);
    document.getElementById("nazioni").value = document.getElementById("CheckedItems").innerHTML;
    });
    });
    </script>
Viewing 1 post (of 1 total)