Hi, can i ask some help ,my problem is that how can i display in the dropdownlist using jquerry.

for example that in my database i have 1 table and 2 columns with 10 records or rows.

assume that i already querried all the colors in the database,but how to display this,

here is my snippet.

$('idselect').change(function(data){

   $('myoption').append('<option></option>').val(data.myval).html(data.mytext);

});

here is the html

<select id="idselect">
   <option id="myoption"></option>

</select>

Thank you in advance.

Here's a code sinnept that may help you, but it's not using jQuery:

<html>
    <script>
        function slcMes_change()
        {
            document.getElementById("slcDia").options.length = 0;

            for(var i=0; i < 31; i++)
            {
                document.getElementById("slcDia").options[i] = new Option(i+1, i+1);
            }
        }   
    </script>
    <body>
        <select id="slcMes" size="1" onchange="slcMes_change()">
            <option value="0">Select</option>
            <option value="1">1</option>
            <option value="2">2</option>
            <option value="3">3</option>
            <option value="4">4</option>
        </select>
        <select id="slcDia" size="1"></select>
    </body>

</html>
Member Avatar for stbuchok

try this (completely untested)

$('#idselect').append('<option value="' + data.myval + '">' + data.mytext + '</option>');

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.