0

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.

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by stbuchok
0

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>
0

try this (completely untested)

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.