based on 1st dropdown, 2nd dropdown value populated from database

puneet kumar
puneet kumar used Ask the Experts™
One drop-down has 2 static value 0 or 1. Based on this selection  2nd drop-down value come from database .

In first drop-down if value is 0 Then Second drop-down static value "ALL"  comes, if first drop-down value is 1 then second drop-down values come from database.

Does anyone have an example of how I can accomplish something like this in JavaScript?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2014
test page :

jQuery(function($) {
   $("#<%= zeroneID.ClientID %>").on("change", function () {
        var v = $(this).val();
        if(v==0) {
            $("#<%= fromdatabaseID.ClientID").prop("disabled", true).hide();
            $("<input id='fromdatabaseINPUT' name='fromdatabase' value='ALL' readonly='readonly' >").insertAfter("#<%= fromdatabaseID.ClientID");
        } else { // v == 1...should....
            $("#<%= fromdatabaseID.ClientID").prop("disabled", false).show();

Open in new window

<select name="zerone" id="zeroneID">
    <option value="0">ZERO</option>
    <option value="1">ONE</option>
<select name="fromdatabase" id="fromdatabaseID">
    <option value="4">4</option>
    <option value="5">5</option>
    <option value="6">6</option>
    <option value="7">7</option>
    <option value="8">8</option>
    <option value="9">9</option>

Open in new window



Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial