1

I'm have multiple tables and have an option dropdown that loops through them. When I tested the code in http://codepen.io/fernandob/pen/JEJRMW , it all works fine but when adding it in my Wordpress page, it doesn't run. In wordpress i'm using visual composer and in a text block, via the text editor i paste the html code, following this.

            <script>
            if (typeof suffixes !== "undefined") {
                suffixes += ",1390152632";
            } else {
                suffixes = "1390152632";
            }
            function  changeCurrency_1390152632() {
               var idx = document.getElementById("id_selected_currency_1390152632").options.selectedIndex;
               var currency = document.getElementById("id_selected_currency_1390152632").options[document.getElementById("id_selected_currency_1390152632").options.selectedIndex].value;
               var currencies = ["EUR", "USD", "GBP"];
               var i, j;
               for (i = 0; i < 3; i++) {
                  var els = document.getElementsByClassName("currency_" + currencies[i]);
                  var cnt = els.length;
                  if (currency == currencies[i]) {
                     for (j = 0; j < cnt; j++) {
                         els[j].style.display = "block";
                     }

                     var a = suffixes.split(",");
                     for (j = 0; j < a.length; j++) {
                        document.getElementById("id_selected_currency_" + a[j]).options.selectedIndex = idx;
                     }

                  } else {
                     for (j = 0; j < cnt; j++) {
                         els[j].style.display = "none";
                     }
                  }
              }
            }
            </script>
2
  • Have you checked the console for errors? Commented Jan 23, 2017 at 17:27
  • hi @hopkins-matt yes i believe i found the answer, for some reason, it's not reading the brackets, in the source code it replaces it with it's HTML equivalent Commented Jan 23, 2017 at 17:44

1 Answer 1

2

It's replace with html code because you are using text block. Use RawHTML and RawJS elements under the structure tab using visual composer. HTML code paste in the Raw HTML element and JavaScrip code paste in the Raw JS element.

See also image:

enter image description here

Hope this answer help you.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.