Javascript: two dropdown redirect submit [duplicate]









up vote
0
down vote

favorite













This question already has an answer here:



  • How do I redirect to another webpage?

    58 answers



i have form two dropdown as:






<form id="redirect">
<select id="location">
<option value="bus">Bus</option>
<option value="station">Station</option>
<option value="office">Office</option>
</select>

<select id="goto">
<option value="home">Home</option>
<option value="city">Cty</option>
</select>

<input type="submit" value="submit"></input>
</form>





How to use Javascript for submit redirect select dropdown as



if #location = Bus && #goto = Home => Click submit redirect =>>google.com



if #location = Bus && #goto = Cty => Click submit redirect =>>facebook.com



match for other #location as



if #location = Station && #goto = Home => Click submit redirect =>>url1.com



if #location = Cty && #goto = Cty => Click submit redirect =>>url2.com



Thank you so much!










share|improve this question













marked as duplicate by Community Nov 12 at 2:59


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


















    up vote
    0
    down vote

    favorite













    This question already has an answer here:



    • How do I redirect to another webpage?

      58 answers



    i have form two dropdown as:






    <form id="redirect">
    <select id="location">
    <option value="bus">Bus</option>
    <option value="station">Station</option>
    <option value="office">Office</option>
    </select>

    <select id="goto">
    <option value="home">Home</option>
    <option value="city">Cty</option>
    </select>

    <input type="submit" value="submit"></input>
    </form>





    How to use Javascript for submit redirect select dropdown as



    if #location = Bus && #goto = Home => Click submit redirect =>>google.com



    if #location = Bus && #goto = Cty => Click submit redirect =>>facebook.com



    match for other #location as



    if #location = Station && #goto = Home => Click submit redirect =>>url1.com



    if #location = Cty && #goto = Cty => Click submit redirect =>>url2.com



    Thank you so much!










    share|improve this question













    marked as duplicate by Community Nov 12 at 2:59


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite












      This question already has an answer here:



      • How do I redirect to another webpage?

        58 answers



      i have form two dropdown as:






      <form id="redirect">
      <select id="location">
      <option value="bus">Bus</option>
      <option value="station">Station</option>
      <option value="office">Office</option>
      </select>

      <select id="goto">
      <option value="home">Home</option>
      <option value="city">Cty</option>
      </select>

      <input type="submit" value="submit"></input>
      </form>





      How to use Javascript for submit redirect select dropdown as



      if #location = Bus && #goto = Home => Click submit redirect =>>google.com



      if #location = Bus && #goto = Cty => Click submit redirect =>>facebook.com



      match for other #location as



      if #location = Station && #goto = Home => Click submit redirect =>>url1.com



      if #location = Cty && #goto = Cty => Click submit redirect =>>url2.com



      Thank you so much!










      share|improve this question














      This question already has an answer here:



      • How do I redirect to another webpage?

        58 answers



      i have form two dropdown as:






      <form id="redirect">
      <select id="location">
      <option value="bus">Bus</option>
      <option value="station">Station</option>
      <option value="office">Office</option>
      </select>

      <select id="goto">
      <option value="home">Home</option>
      <option value="city">Cty</option>
      </select>

      <input type="submit" value="submit"></input>
      </form>





      How to use Javascript for submit redirect select dropdown as



      if #location = Bus && #goto = Home => Click submit redirect =>>google.com



      if #location = Bus && #goto = Cty => Click submit redirect =>>facebook.com



      match for other #location as



      if #location = Station && #goto = Home => Click submit redirect =>>url1.com



      if #location = Cty && #goto = Cty => Click submit redirect =>>url2.com



      Thank you so much!





      This question already has an answer here:



      • How do I redirect to another webpage?

        58 answers






      <form id="redirect">
      <select id="location">
      <option value="bus">Bus</option>
      <option value="station">Station</option>
      <option value="office">Office</option>
      </select>

      <select id="goto">
      <option value="home">Home</option>
      <option value="city">Cty</option>
      </select>

      <input type="submit" value="submit"></input>
      </form>





      <form id="redirect">
      <select id="location">
      <option value="bus">Bus</option>
      <option value="station">Station</option>
      <option value="office">Office</option>
      </select>

      <select id="goto">
      <option value="home">Home</option>
      <option value="city">Cty</option>
      </select>

      <input type="submit" value="submit"></input>
      </form>






      javascript redirect dropdown






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 at 2:41









      DinhCode

      587




      587




      marked as duplicate by Community Nov 12 at 2:59


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






      marked as duplicate by Community Nov 12 at 2:59


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote



          accepted










          Here's how you'd do it:



          var form = document.getElementById("redirect");
          form.onsubmit = function()
          var location = document.getElementById("location").value;
          var goto = document.getElementById("goto").value;
          if (location == "Bus")
          if (goto == "Home")
          window.location.href = "https://google.com";

          else
          window.location.href = "https://facebook";

          else
          if (goto == "Home")
          window.location = "a url";

          else
          window.location.href = "another url";





          Change those URLs as you'd like.






          share|improve this answer



























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote



            accepted










            Here's how you'd do it:



            var form = document.getElementById("redirect");
            form.onsubmit = function()
            var location = document.getElementById("location").value;
            var goto = document.getElementById("goto").value;
            if (location == "Bus")
            if (goto == "Home")
            window.location.href = "https://google.com";

            else
            window.location.href = "https://facebook";

            else
            if (goto == "Home")
            window.location = "a url";

            else
            window.location.href = "another url";





            Change those URLs as you'd like.






            share|improve this answer
























              up vote
              0
              down vote



              accepted










              Here's how you'd do it:



              var form = document.getElementById("redirect");
              form.onsubmit = function()
              var location = document.getElementById("location").value;
              var goto = document.getElementById("goto").value;
              if (location == "Bus")
              if (goto == "Home")
              window.location.href = "https://google.com";

              else
              window.location.href = "https://facebook";

              else
              if (goto == "Home")
              window.location = "a url";

              else
              window.location.href = "another url";





              Change those URLs as you'd like.






              share|improve this answer






















                up vote
                0
                down vote



                accepted







                up vote
                0
                down vote



                accepted






                Here's how you'd do it:



                var form = document.getElementById("redirect");
                form.onsubmit = function()
                var location = document.getElementById("location").value;
                var goto = document.getElementById("goto").value;
                if (location == "Bus")
                if (goto == "Home")
                window.location.href = "https://google.com";

                else
                window.location.href = "https://facebook";

                else
                if (goto == "Home")
                window.location = "a url";

                else
                window.location.href = "another url";





                Change those URLs as you'd like.






                share|improve this answer












                Here's how you'd do it:



                var form = document.getElementById("redirect");
                form.onsubmit = function()
                var location = document.getElementById("location").value;
                var goto = document.getElementById("goto").value;
                if (location == "Bus")
                if (goto == "Home")
                window.location.href = "https://google.com";

                else
                window.location.href = "https://facebook";

                else
                if (goto == "Home")
                window.location = "a url";

                else
                window.location.href = "another url";





                Change those URLs as you'd like.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 at 2:46









                Jack Bashford

                4,42931234




                4,42931234













                    Popular posts from this blog

                    27

                    Top Tejano songwriter Luis Silva dead of heart attack at 64

                    Category:Rhetoric