0

I'm using the following code to create a menu, where when one is clicked, it will take you to a specified url in a case statement. I don't understand what to use in each case statement in order to get this to work. Here is the code, right now it goes nowhere when clicked:

<body>
        <div id="page3" class="page">
            <div class="form">
                    <div class="text">4 Item Menu</div>
                    <div class="selection" id="fs_3"></div>
                </div>
            </div>
        </div>

        <script src="plugin/react-with-addons.min.js" charset="utf-8"></script>
        <script src="plugin/react-dom.min.js" charset="utf-8"></script>
        <script src="plugin/app.js" charset="utf-8"></script>

        <script type="text/javascript">
        new CA_select({
            selector: document.getElementById('fs_3'),
            iconColor: '#fff',
            bgColor: '#00BCD4',
            items: [
                {class: "fa-thumbs-up"},
                {class: "fa-thumbs-down"},
                {class: "fa-arrow-right"},
                {class: "fa-arrow-left"},
            ],
            callback: true,
            change: (ret) => {
                 switch(ret) {
        case "0":
         window.location.assign("http://www.google.com");
         break;
        case "1":
         window.location.assign("http://www.cnn.com");
         break;
        case "2":
         window.location.assign("http://www.msn.com");
         break;
        case "3":
         window.location.assign("http://www.espn.com");
         break;              
   }                
        }
        })
        </script>
    </body>
sushain97
  • 2,752
  • 1
  • 25
  • 36
Elias
  • 3
  • 4

1 Answers1

0

you have to add form tag in html and then you can use action from javascript like in case just add

 document.getElementById("myForm").action="http://www.google.com";
 document.getElementById("myForm").submit();

and in html

<form id="myForm" action="">
<div id="page3" class="page">
            <div class="form">
                    <div class="text">4 Item Menu</div>
                    <div class="selection" id="fs_3"></div>
                </div>
            </div>
        </div>
</form>

check How to set form action through JavaScript?

SF..MJ
  • 862
  • 8
  • 19