• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

drop down menu link

Engaged ,
Aug 06, 2015 Aug 06, 2015

Copy link to clipboard

Copied

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

Views

396

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 07, 2015 Aug 07, 2015

Copy link to clipboard

Copied

LATEST

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>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation