Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
4.00/5 (1 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 .
HTML
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:
HTML
A-drop downlist                                          B-drop downlist
C                                                          003 


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

1 solution

Hi Member 10463904,

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

HTML
ASP.NET
<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)
ASP.NET
<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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900