Click here to Skip to main content
15,867,756 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi ;

i have 2 javascript but they are not working on same page, how i can fix it ?

Thanks for helps
Best regards
Marco

first javascript :

JavaScript
<script type="text/javascript">
    function configureDropDownLists(XLEW_3_5_3,XLEW_3_6_3) {
        var K31_213mm = new Array('90', '106');
        var K32_245mm = new Array('90', '106');
        var K33_338mm = new Array('90', '106');
		var K31D_213mm = new Array('106', '160');
		var K32D_245mm = new Array('106', '160');
		var K33D_338mm = new Array('106', '160');
		var K31_LH_213mm = new Array('77');
		var K32_LH_245mm = new Array('77');

        switch (XLEW_3_5_3.value) {
            case 'K31_213mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K31_213mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K31_213mm[i], K31_213mm[i]);
                }
                break;
            case 'K32_245mm':
                document.getElementById(XLEW_3_6_3).options.length = 0; 
            for (i = 0; i < K32_245mm.length; i++) {
                createOption(document.getElementById(XLEW_3_6_3), K32_245mm[i], K32_245mm[i]);
                }
                break;
            case 'K33_338mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K33_338mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K33_338mm[i], K33_338mm[i]);
                }
                break;
				case 'K31D_213mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K31D_213mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K31D_213mm[i], K31D_213mm[i]);
                }
                break;
				case 'K32D_245mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K32D_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K32D_245mm[i], K32D_245mm[i]);
                }
                break;
				case 'K33D_338mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K33D_338mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K33D_338mm[i], K33D_338mm[i]);
                }
                break;
				case 'K31_LH_213mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K31_LH_213mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K31_LH_213mm[i], K31_LH_213mm[i]);
                }
                break;
				case 'K32_LH_245mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K32_LH_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K32_LH_245mm[i], K32_LH_245mm[i]);
                }
                break;
                default:
                    document.getElementById(XLEW_3_6_3).options.length = 0;
                break;
        }

    }

    function createOption(XLEW_3_5_3, text, value) {
        var opt = document.createElement('option');
        opt.value = value;
        opt.text = text;
        XLEW_3_5_3.options.add(opt);
    }
</script>

<select id="XLEW_3_5_3" onchange="configureDropDownLists(this,'XLEW_3_6_3')">
<option value="K31_213mm">K31 / 213mm</option>
<option value="K32_245mm">K32 / 245mm</option>
<option value="K33_338mm">K33 / 338mm</option>
<option value="K31D_213mm">K31D / 213mm</option>
<option value="K32D_245mm">K32D / 245mm</option>
<option value="K33D_338mm">K33D / 338mm</option>
<option value="K31_LH_213mm">K31-LH / 213mm</option>
<option value="K32_LH_245mm">K32-LH / 245mm</option>
</select>

<select id="XLEW_3_6_3">
</select>
</body>
</html


Second Javascript :

JavaScript
<script type="text/javascript">

    function configureDropDownLists(XLEW_4_5_3,XLEW_4_6_3) {
        var KFT31_245mm = new Array('90', '106');
        var KFT32_345mm = new Array('90', '106');
        var KFT33_415mm = new Array('90', '106');
		var KFT31D_245mm = new Array('106', '160');
		var KFT32D_345mm = new Array('106', '160');
		var KFT33D_415mm = new Array('106', '160');
		var KFT31_LH_245mm = new Array('77');
		var KFT32_LH_345mm = new Array('77');

        switch (XLEW_4_5_3.value) {
            case 'KFT31_245mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT31_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT31_245mm[i], KFT31_245mm[i]);
                }
                break;
            case 'KFT32_345mm':
                document.getElementById(XLEW_4_6_3).options.length = 0; 
            for (i = 0; i < KFT32_345mm.length; i++) {
                createOption(document.getElementById(XLEW_4_6_3), KFT32_345mm[i], KFT32_345mm[i]);
                }
                break;
            case 'KFT33_415mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT33_415mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT33_415mm[i], KFT33_415mm[i]);
                }
                break;
				case 'KFT31D_245mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT31D_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT31D_245mm[i], KFT31D_245mm[i]);
                }
                break;
				case 'KFT32D_345mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT32D_345mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT32D_345mm[i], KFT32D_345mm[i]);
                }
                break;
				case 'KFT33D_415mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT33D_415mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT33D_415mm[i], KFT33D_415mm[i]);
                }
                break;
				case 'KFT31_LH_245mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT31_LH_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT31_LH_245mm[i], KFT31_LH_245mm[i]);
                }
                break;
				case 'KFT32_LH_345mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT32_LH_345mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT32_LH_345mm[i], KFT32_LH_345mm[i]);
                }
                break;
                default:
                    document.getElementById(XLEW_4_6_3).options.length = 0;
                break;
        }

    }

    function createOption(XLEW_4_5_3, text, value) {
        var opt = document.createElement('option');
        opt.value = value;
        opt.text = text;
        XLEW_4_5_3.options.add(opt);
    }
</script>
<select id="XLEW_4_5_3" onchange="configureDropDownLists(this,'XLEW_4_6_3')">
<option value="KFT31_245mm">KFT31 / 245mm</option>
<option value="KFT32_345mm">KFT32 / 345mm</option>
<option value="KFT33_415mm">KFT33 / 415mm</option>
<option value="KFT31D_245mm">KFT31D / 245mm</option>
<option value="KFT32D_345mm">KFT32D / 345mm</option>
<option value="KFT33D_415mm">KFT33D / 415mm</option>
<option value="KFT31_LH_245mm">KFT31-LH / 245mm</option>
<option value="KFT32_LH_345mm">KFT32_LH_345mm</option>
</select>

<select id="XLEW_4_6_3">
</select>
</body>
</html>
Posted
Updated 13-Aug-12 4:59am
v2
Comments
[no name] 13-Aug-12 11:02am    
You mean not working as in they are named the same? Change one of the functions names.
mcrbne 13-Aug-12 11:07am    
how can i do it ? really i am not good about such things and i have no idea how i can do it...
ZurdoDev 13-Aug-12 11:13am    
What's not working?
mcrbne 13-Aug-12 11:14am    
i am trying to use this 2 Javascript on same webpage but its crashing and not working , actually 1 script working otherone not working...
ZurdoDev 13-Aug-12 11:18am    
But what do you mean by not working? Is there an error?

If both the javascript functions are doing the same thing, then why you have created one more function. better to call the same function configureDropDownLists in another place also.


Thanks
Ashish
 
Share this answer
 
Comments
mcrbne 13-Aug-12 11:29am    
i understand your mean but i dont know how to do it ! i am not javascript coder... :(
AshishChaudha 13-Aug-12 11:47am    
is problem solved?? then mark your answer as a solution..please..so that other can refer to the solution.
Abdul Quader Mamun 13-Aug-12 11:34am    
long question but short easy answer!
Rahul Rajat Singh 14-Aug-12 0:43am    
+5. good answer
try this...perfectly working

XML
<script type="text/javascript">
    function configureDropDownLists(XLEW_3_5_3,XLEW_3_6_3) {
        var K31_213mm = new Array('90', '106');
        var K32_245mm = new Array('90', '106');
        var K33_338mm = new Array('90', '106');
        var K31D_213mm = new Array('106', '160');
        var K32D_245mm = new Array('106', '160');
        var K33D_338mm = new Array('106', '160');
        var K31_LH_213mm = new Array('77');
        var K32_LH_245mm = new Array('77');

        switch (XLEW_3_5_3.value) {
            case 'K31_213mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K31_213mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K31_213mm[i], K31_213mm[i]);
                }
                break;
            case 'K32_245mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
            for (i = 0; i < K32_245mm.length; i++) {
                createOption(document.getElementById(XLEW_3_6_3), K32_245mm[i], K32_245mm[i]);
                }
                break;
            case 'K33_338mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K33_338mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K33_338mm[i], K33_338mm[i]);
                }
                break;
                case 'K31D_213mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K31D_213mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K31D_213mm[i], K31D_213mm[i]);
                }
                break;
                case 'K32D_245mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K32D_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K32D_245mm[i], K32D_245mm[i]);
                }
                break;
                case 'K33D_338mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K33D_338mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K33D_338mm[i], K33D_338mm[i]);
                }
                break;
                case 'K31_LH_213mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K31_LH_213mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K31_LH_213mm[i], K31_LH_213mm[i]);
                }
                break;
                case 'K32_LH_245mm':
                document.getElementById(XLEW_3_6_3).options.length = 0;
                for (i = 0; i < K32_LH_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_3_6_3), K32_LH_245mm[i], K32_LH_245mm[i]);
                }
                break;
                default:
                    document.getElementById(XLEW_3_6_3).options.length = 0;
                break;
        }

    }

    function createOption(XLEW_3_5_3, text, value) {
        var opt = document.createElement('option');
        opt.value = value;
        opt.text = text;
        XLEW_3_5_3.options.add(opt);
    }
    </script>

    <script type="text/javascript">

    function configureDropDownLists1(XLEW_4_5_3,XLEW_4_6_3) {
        var KFT31_245mm = new Array('90', '106');
        var KFT32_345mm = new Array('90', '106');
        var KFT33_415mm = new Array('90', '106');
        var KFT31D_245mm = new Array('106', '160');
        var KFT32D_345mm = new Array('106', '160');
        var KFT33D_415mm = new Array('106', '160');
        var KFT31_LH_245mm = new Array('77');
        var KFT32_LH_345mm = new Array('77');

        switch (XLEW_4_5_3.value) {
            case 'KFT31_245mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT31_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT31_245mm[i], KFT31_245mm[i]);
                }
                break;
            case 'KFT32_345mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
            for (i = 0; i < KFT32_345mm.length; i++) {
                createOption(document.getElementById(XLEW_4_6_3), KFT32_345mm[i], KFT32_345mm[i]);
                }
                break;
            case 'KFT33_415mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT33_415mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT33_415mm[i], KFT33_415mm[i]);
                }
                break;
                case 'KFT31D_245mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT31D_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT31D_245mm[i], KFT31D_245mm[i]);
                }
                break;
                case 'KFT32D_345mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT32D_345mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT32D_345mm[i], KFT32D_345mm[i]);
                }
                break;
                case 'KFT33D_415mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT33D_415mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT33D_415mm[i], KFT33D_415mm[i]);
                }
                break;
                case 'KFT31_LH_245mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT31_LH_245mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT31_LH_245mm[i], KFT31_LH_245mm[i]);
                }
                break;
                case 'KFT32_LH_345mm':
                document.getElementById(XLEW_4_6_3).options.length = 0;
                for (i = 0; i < KFT32_LH_345mm.length; i++) {
                    createOption(document.getElementById(XLEW_4_6_3), KFT32_LH_345mm[i], KFT32_LH_345mm[i]);
                }
                break;
                default:
                    document.getElementById(XLEW_4_6_3).options.length = 0;
                break;
        }

    }

    function createOption(XLEW_4_5_3, text, value) {
        var opt = document.createElement('option');
        opt.value = value;
        opt.text = text;
        XLEW_4_5_3.options.add(opt);
    }
    </script>

</head>
<body>
    <select id="XLEW_4_5_3" onchange="configureDropDownLists1(this,'XLEW_4_6_3')">
        <option value="KFT31_245mm">KFT31 / 245mm</option>
        <option value="KFT32_345mm">KFT32 / 345mm</option>
        <option value="KFT33_415mm">KFT33 / 415mm</option>
        <option value="KFT31D_245mm">KFT31D / 245mm</option>
        <option value="KFT32D_345mm">KFT32D / 345mm</option>
        <option value="KFT33D_415mm">KFT33D / 415mm</option>
        <option value="KFT31_LH_245mm">KFT31-LH / 245mm</option>
        <option value="KFT32_LH_345mm">KFT32_LH_345mm</option>
    </select>
    <select id="XLEW_4_6_3">
    </select>
    <select id="XLEW_3_5_3" onchange="configureDropDownLists(this,'XLEW_3_6_3')">
        <option value="K31_213mm">K31 / 213mm</option>
        <option value="K32_245mm">K32 / 245mm</option>
        <option value="K33_338mm">K33 / 338mm</option>
        <option value="K31D_213mm">K31D / 213mm</option>
        <option value="K32D_245mm">K32D / 245mm</option>
        <option value="K33D_338mm">K33D / 338mm</option>
        <option value="K31_LH_213mm">K31-LH / 213mm</option>
        <option value="K32_LH_245mm">K32-LH / 245mm</option>
    </select>
    <select id="XLEW_3_6_3">
    </select>
</body>
</html>



thanks
ashish
 
Share this answer
 
Comments
Abdul Quader Mamun 13-Aug-12 12:10pm    
good Work!
AshishChaudha 13-Aug-12 12:12pm    
Thanks abdul..
mcrbne 13-Aug-12 12:54pm    
if you are not busy , i have another question my friend, may i ask ?
mcrbne 13-Aug-12 12:21pm    
Thanks A LOT ashish !
mcrbne 13-Aug-12 12:50pm    
if you are not busy , i have another question my friend, may i ask ?

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