1 Reply Latest reply on Aug 7, 2015 1:04 AM by haxtbh

    drop down menu link

    jamie61880 Level 1

      Hi. I just have a simple drop down menu. I would just like to have one of the options be a link. How do I do that? I thought I found something yesterday that would work, but it doesn't. Here's what I found:

       

      <select name="Socket_Adapter_Choice" onchange="location = this.options[this.selectedIndex].value;">

        <option selected value=""></option>

          <option value="Add_Socket_App.cfm">Add Socket Application</option>

        <option value="Add_Adapter_App.cfm">Add Adapter Application</option>

        </select>

       

      Thanks.

      Andy

        • 1. Re: drop down menu link
          haxtbh Level 4

          Google is you friend! There are so many results just for this type of question on stackoverflow.

           

          Anyway, you will need to do something liek this:

           

          <select name="Socket_Adapter_Choice" onchange="window.location.href = this.value">
                   <option selected value=""></option>
                   <option value="Add_Socket_App.cfm">Add Socket Application</option>
                   <option value="Add_Adapter_App.cfm">Add Adapter Application</option>
          </select>
          
          

           

          The problem you might have is if someone selects the blank option you have. Ideally you want the onChange event to fire a function that checks its not blank and then changes the url.

           

          <select name="Socket_Adapter_Choice" onchange="goToPage(this.value);">
                   <option selected value=""></option>
                   <option value="Add_Socket_App.cfm">Add Socket Application</option>
                   <option value="Add_Adapter_App.cfm">Add Adapter Application</option>
          </select>
          
          <script type="text/javascript">
             function goToPage(url)
             {
                  if(url != '') {
                       window.location.href = url;
                  }
             }
          </script>