Highlighted

drop down menu link

Engaged ,
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

341

Likes

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

drop down menu link

Engaged ,
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

342

Likes

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
Aug 06, 2015 0
haxtbh LATEST
Advocate ,
Aug 07, 2015

Copy link to clipboard

Copied

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>

Likes

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
Reply
Loading...
Aug 07, 2015 0