Hi ;

i have 2 javascript , but they dont work on same page , how can i do it ?

This is the first one :

<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>

This is the second one :

<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>

Thanks For Helps
Best Regards

They don't work because both of them have the exact function name -- configureDropDownLists. What you may do is to change the function name from one of them and don't forget to change the call name to match the name you change.

i.e. change the function name in portion #2, line 2 from configureDropDownLists(XLEW_4_5_3,XLEW_4_6_3) to configureDropDownLists2(XLEW_4_5_3,XLEW_4_6_3), and then change function call in line 75 from configureDropDownLists(this,'XLEW_4_6_3') to configureDropDownLists2(this,'XLEW_4_6_3').

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.