• I have this Dependable drop down menu which is working on all modern browsers but not working in old Explorer or inside WordPress Shortcode widget.

    https://errorcodeappliancerepair.ca/estimates.html

    I think there is an error somewhere because when I use this code inside Shortcode widgets half of the script works, but last dropdown menu is not reading data from the function dynamicdropdown(listindex)

    Here is that code responsible for that functionality.

    <div class="container">
                <!-- <title>Dynamic Drop Down List</title> -->
                <div class="container-brand">
                    <label for="brand">Choose your Brand: </label>
                    <select id="brand" name="brand">
                        <option value="" >Select Brand</option>
                        <option value="1" >LG</option>
                        <option value="1" >Samsung</option>
                        <option value="1.2" >Whirlpool</option>
                        <option value="1.5" >Bosch</option>
                        <option value="1.4" >Frigidaire</option>
                        <option value="2" >GE</option>
                        <option value="1.3" >Electrolux</option>
                        <option value="1.3" >Maytag</option>
                        <option value="1.6" >Kitchen Aid</option>
                        <option value="1.2" >Kenmore</option>
                    </select>
                </div>
              
                <div class="category_div" id="category_div">Select your Appliance:
                    <select name="category" class="required-entry" id="category" onchange="javascript: dynamicdropdown(this.options[this.selectedIndex].value);">
                        <option value="">Select Appliance</option>
                        <option value="1.2">Washer</option>
                        <option value="1">Dryer</option>
                        <option value="1.5">Dishwasher</option>
                        <option value="1.4">Gas Range</option>
                        <option value="1.3">Electric Range</option>
                        <option value="1.6">Refrigirator</option>
                        <option value="1.1">Microwave</option>
                    </select>
                </div>
        
                <div class="sub_category_div" id="sub_category_div">Select Issue:
                    <script type="text/javascript" language="JavaScript">
                        document.write('<select name="subcategory" id="subcategory"><option value="">Select Issue</option></select>')
                    </script>
           
                </div>
                    
                <button type="button" onclick="myFunction3()">Calculate</button>
        
                <p id="demo3">Result</p>
        
                <script>
                    function myFunction3() 
                {
                    var x = document.getElementById("brand").value;
                    var y = document.getElementById("subcategory").value;
                    
                    document.getElementById("demo3").innerHTML = ((y*50*x)+50);
        
                }
                </script>
            </div>
       
        
        <script language="javascript" type="text/javascript">
    
            function dynamicdropdown(listindex)
            {
                document.getElementById("subcategory").length = 0;
                switch (listindex)
                {
                    case "1.2" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("Not Draining","1");
                        document.getElementById("subcategory").options[2]=new Option("Not Filling","1");
                        document.getElementById("subcategory").options[3]=new Option("Not Spinning","1.5");
                        document.getElementById("subcategory").options[4]=new Option("Not Starting","1.3");
                        document.getElementById("subcategory").options[5]=new Option("Works intermittently","2");
                        document.getElementById("subcategory").options[6]=new Option("Leaking","1.2");
                        break;           
                    case "1" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("No Heat","1.5");
                        document.getElementById("subcategory").options[2]=new Option("No Power","1.2");
                        document.getElementById("subcategory").options[3]=new Option("Will not Start","1.2");
                        document.getElementById("subcategory").options[4]=new Option("Works Intermittently","2");
                        document.getElementById("subcategory").options[5]=new Option("Noise","1.6");
                        break;
                    case "1.5" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("Not Draining","0.6");
                        document.getElementById("subcategory").options[2]=new Option("Not Filling","1");
                        document.getElementById("subcategory").options[3]=new Option("Making Noise","1.6");
                        document.getElementById("subcategory").options[4]=new Option("Not Cleaning","1.5");
                        document.getElementById("subcategory").options[5]=new Option("Does not Turn On","1.8");
                        document.getElementById("subcategory").options[6]=new Option("Leaking","2");     
                        break;
                    case "1.4" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("Keeps Clicking","1.1");
                        document.getElementById("subcategory").options[2]=new Option("No Light No Power","1.2");
                        document.getElementById("subcategory").options[3]=new Option("Oven not Heating","1.1");
                        document.getElementById("subcategory").options[4]=new Option("Burner not Working","1.4");
                        document.getElementById("subcategory").options[5]=new Option("No Spark","1.3");
                        break;
                    case "1.3" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("Element Stuck On High","1");
                        document.getElementById("subcategory").options[2]=new Option("Broil not Working","0.6");
                        document.getElementById("subcategory").options[3]=new Option("Bake not Working","0.6");
                        document.getElementById("subcategory").options[4]=new Option("Element will not Heat","0.8");
                        document.getElementById("subcategory").options[5]=new Option("No Power","1");
                        document.getElementById("subcategory").options[6]=new Option("Temperature Issues","1.4");
                        break;
                    case "1.6" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("Leaking","1.2");
                        document.getElementById("subcategory").options[2]=new Option("Both Compartments not Cooling","1.7");
                        document.getElementById("subcategory").options[3]=new Option("Fridge not Cooling","1.2");
                        document.getElementById("subcategory").options[4]=new Option("Freezer not Cooling","1.4");
                        document.getElementById("subcategory").options[5]=new Option("Ice Maker Issue","1.8");
                        document.getElementById("subcategory").options[6]=new Option("Noisy","2");
                        break;
                    case "1.1" :
                        document.getElementById("subcategory").options[0]=new Option("Select Issue","");
                        document.getElementById("subcategory").options[1]=new Option("Not Heating","1.2");
                        document.getElementById("subcategory").options[2]=new Option("Will not Turn Table","1");
                        document.getElementById("subcategory").options[3]=new Option("Humming Noise","1.8");
                        document.getElementById("subcategory").options[4]=new Option("No Power No Lights","1");
                        document.getElementById("subcategory").options[5]=new Option("Display does not Work","1.1");
                        document.getElementById("subcategory").options[6]=new Option("Runs but Shuts off Soon","1.3");
                        break;
                }
                return true;
            }
    
        </script>

    Expand snippet
    This is what is shows up in WordPress Page if I paste the code into Shortcode widgets:

    I can not post pictures here so you have to follow that link to see that I mean: http://olege4.sg-host.com/quote/

    As you can see it even works inside the snippet but not inside WordPress and not inside old Explorer. No options show up under Select issues menu.

    Any suggestions?

    • This topic was modified 4 years, 8 months ago by alectech.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • I was able to reproduce this locally by dropping this code into Shortcode block. I don’t believe that this is the correct way to do this as there are formatting issues and console errors being fired.

    If you want to use a shortcode, you should use the Shortcode API to register the shortcode and then add it in the block.

    wow.
    I think it’s time to implement a more robust application.

    Apart from that, to answer your question, see screenshot:
    https://postimg.cc/B8tDKdJt

    You don’t have an onChange set on your Issue dropdown – but the error must be coming from a conflict in your site since it works fine here:
    https://corrinaonline.com/onchange/

    Thread Starter alectech

    (@alectech)

    Thank you, I will try re-factor the code and maybe use shortcode API technique.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Shortcode widget not working as expected’ is closed to new replies.