Click here to Skip to main content
14,388,136 members
Rate this:
Please Sign up or sign in to vote.
See more:
Please any one help below requirements. It would be very useful for me . Advance Thanks

Please any one help below requirements. It would be very useful for me . Advance Thanks

for example I have two dropdown list in form , If I click values in first dropdown list. automaticaly respective values to show the scecond in drop down list .
A- dropdown list         B- drop down list
 
A                        001
B                        002
C                        003


for example If I click values "C" in first dropdown list. automaticaly respective values to show "003" the scecond in drop down list

Reference:
A-drop downlist                                          B-drop downlist
C                                                          003 


i am new to JavaScript please any one help me ...
Posted
Updated 29-Oct-14 21:31pm
v2

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Hi Member 10463904,

I have prepared a sample for your reference, please go through the below code example :

HTML
<form id="form1" runat="server">
    <div>
    <select id="dpdFirst">
        <option value="A">A</option>
        <option value="B">B</option>
        <option value="C">C</option>
    </select>
    <select id="dpdSecond">
        <option value="1">001</option>
        <option value="2">002</option>
        <option value="3">003</option>
    </select>
    </div>
    </form>


SCRIPT(jQuery)
<head runat="server">
    <title></title>
    <script src="Script/jquery-2.0.3.js"></script>
    <script type="text/javascript">
       <pre lang="Javascript"> $(function () {
            $('#dpdFirst').change(function () {
                var vFirst = $('#dpdFirst option:selected').text();
                switch (vFirst) {
                    case 'A':
                        $('#dpdSecond').val(1);
                        break;
                    case 'B':
                        $('#dpdSecond').val(2);
                        break;
                    case 'C':
                        $('#dpdSecond').val(3);
                        break;
                }
            });
        });





Hope this will definitely of help.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100