Select with checkbox

Asked

Viewed 101 times

0

Guys, my question is, would I make a query in mysql bank and play instead of cities ?

<html>
<head>
    <title></title>

    <link href="http://cdn-na.infragistics.com/igniteui/2017.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
    <link href="http://cdn-na.infragistics.com/igniteui/2017.1/latest/css/structure/infragistics.css" rel="stylesheet" />

    <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
    <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

    <script src="http://cdn-na.infragistics.com/igniteui/2017.1/latest/js/infragistics.core.js"></script>
    <script src="http://cdn-na.infragistics.com/igniteui/2017.1/latest/js/infragistics.lob.js"></script>

</head>
<body>
    <style>        
        .combo-label {margin-bottom:.5em;}
    </style>
    <h4 class="combo-label">Selecione as matrículas:</h4>
    <div id="checkboxSelectCombo"></div>

    <script>

        var colors = [
            { Name: "Cidades" },
            { Name: "São Paulo" },
            { Name: "Rio de Janeiro" },
            { Name: "Controle" },
            { Name: "Android" },
            { Name: "Maria" },
            { Name: "joão" },
            { Name: "Plus" },
            { Name: "teste" }
        ];

        $(function () {

            $("#checkboxSelectCombo").igCombo({
                width: 300,
                dataSource: colors,
                textKey: "Name",
                valueKey: "Name",
                multiSelection: {
                    enabled: true,
                    showCheckboxes: true
                },
                dropDownOrientation: "bottom"
            });

        });

    </script>

</body>
</html>
  • would have yes, save in an array the query and then go through acquiring values where you want

  • Because I am very inexperienced with ajax and tals, would you help more specifically ? as I should change and comment to me know ?

2 answers

0

Follow your updated code as you requested.

<html>
    <head>
        <title></title>

        <link href="http://cdn-na.infragistics.com/igniteui/2017.1/latest/css/themes/infragistics/infragistics.theme.css" rel="stylesheet" />
        <link href="http://cdn-na.infragistics.com/igniteui/2017.1/latest/css/structure/infragistics.css" rel="stylesheet" />

        <script src="http://ajax.aspnetcdn.com/ajax/modernizr/modernizr-2.8.3.js"></script>
        <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
        <script src="http://code.jquery.com/ui/1.11.1/jquery-ui.min.js"></script>

        <script src="http://cdn-na.infragistics.com/igniteui/2017.1/latest/js/infragistics.core.js"></script>
        <script src="http://cdn-na.infragistics.com/igniteui/2017.1/latest/js/infragistics.lob.js"></script>

    </head>
    <body>
        <style>        
            .combo-label {margin-bottom:.5em;}
        </style>
        <h4 class="combo-label">Selecione as cidades:</h4>
        <div id="checkboxSelectCombo"></div>

        <script>

            $(function () {

                cidades;

                $.get("urlquebuscacidades", function(retorno){
                    /*lá no retorno do .php, deve retornar um objeto ou array, e voce popula sua var no js*/
                    cidades = retorno;
                });

                $("#checkboxSelectCombo").igCombo({
                    width: 300,
                    dataSource: cidades,
                    textKey: "Name",
                    valueKey: "Name",
                    multiSelection: {
                        enabled: true,
                        showCheckboxes: true
                    },
                    dropDownOrientation: "bottom"
                });

            });

        </script>

    </body>
    </html>
  • Because I am very inexperienced with ajax and tals, would you help more specifically ? as I should change and comment to me know ?

  • Blz. In the php part it is quiet to perform the query and return on the screen?

  • Yes, do the queries yes. store in variables, everything ok, just do not know pass them to the script and vice versa.

0

use ajax! example:

$.post("insertCidades.php", { cidades: colors }, function(result){
    $("#resultado").html(result); // imprimir o resultado
});

in the archive insertCidades.php

$cidadesArray = $_REQUEST['cidades'];
// agora inserir na base de dados podes usar um while

to test if everything is ok, does print_r($cityArray) and in the div with id #outworking will contain the array you sent

  • Hello, thanks for helping me, but I need some more details I’m still venturing into ajax, I do not know how to proceed right, I understand php. anyone can give more details ? and separate into files ?

  • Because I am very inexperienced with ajax and tals, would you help more specifically ? as I should change and comment to me know ?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.