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.




here is the html

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


Thank you in advance.

Recommended Answers

All 2 Replies

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

        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);
        <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 id="slcDia" size="1"></select>

Member Avatar

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, learning, and sharing knowledge.