mercredi 25 avril 2018

redirect the user to specific page based on select tag by javascript?

I'm trying to redirect the user based on select HTML tag by javascript I also need to set the word admin for both user and password?

enter image description here

function myFunction() {
        var x = document.getElementById("mySelect");
        var i = x.selectedIndex;

        if (x.options[i].text === "Building 1") {
                window.location.href = "../../realview/Building1/";
        } else if (x.options[i].text === "Building 2") {
                window.location.href = "../../realview/Building2/";
        } else if (x.options[i].text === "Building 3") {
                window.location.href = "../../realview/Building3/";
        } else if (x.options[i].text === "Building 4") {
                window.location.href = "../../realview/Building4/";
        } else if (x.options[i].text === "Building 5") {
                window.location.href = "../../realview/Building5/";
        } else if (x.options[i].text === "Building 6") {
                window.location.href = "../../realview/Building6/";
        } else {
                window.location.href = "../../realview/Building7/";
        }
}
                                             <select id="mySelect" class="login100-form" >
                                                  <option value="Building 1">Building 1</option>
                                                  <option value="Building 2">Building 2</option>
                                                  <option value="Building 3">Building 3</option>
                                                  <option value="Building 4">Building 4</option>
                                                  <option value="Building 5">Building 5</option>
                                                  <option value="Building 6">Building 6</option>
                                                  <option value="Building 7">Building 7</option>
                                                </select>

                                                <div  class="container-login100-form-btn" onclick="myFunction()" >
                                                        <!-- <a href="" target="blank" class="login100-form-btn"  > -->
                                                                <button type="button" class="login100-form-btn"  >
                                                                        Login
                                                                </button>                                                         
                                                        </a>
                                            </div>

Aucun commentaire:

Enregistrer un commentaire