Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 275
  • Last Modified:

drop down select menu to load link

Hello All,

I need to set up a html drop down menu that sends the user to a specific url upon clicking the choice. Any help would be great. I will attach the code below. Thanks.
<select class="fl" style="padding:6px 8px;height:32px;margin-right:10px;">
  <option>Pick a region</option>
  <option>New York</option>
  <option>Philidelphia</option>
  <option>Pittsburg</option>
  <option>Tampa Bay</option>
</select>
<a href="javascript:void(0);" class="button">Ok</a>

Open in new window

0
yando18
Asked:
yando18
1 Solution
 
erikTsomikSystem Architect, CF programmer Commented:
you can do something like this
<select onchange="window.open(this.options[this.selectedIndex].value,'_top')" class="fl" style="padding:6px 8px;height:32px;margin-right:10px;">

    <option value=">Pick a region</option>
  <option value="http://newyour.com">New York</option>
  <option value="http://Philidelphia.com">Philidelphia</option>
  <option>Pittsburg</option>
  <option>Tampa Bay</option>
</select>
0
 
HainKurtSr. System AnalystCommented:
or something like this
<script>
function openURL(url){
  if (url != "") window.open(url,'_top');
}
</script>

<select onchange="openURL(this.value)" class="fl" style="padding:6px 8px;height:32px;margin-right:10px;">
  <option value="">Pick a region</option>
  <option value="http://newyork.com">New York</option>
  <option value="http://Philidelphia.com">Philidelphia</option>
  <option value="http://Pittsburg.com">Pittsburg</option>
  <option value="http://TampaBay.com">Tampa Bay</option>
</select>

Open in new window

0
 
HainKurtSr. System AnalystCommented:
or this using a button
<script>
function openURL(url){
  if (url != "") window.open(url,'_top');
}
</script>

<select id=selURL class="fl" style="padding:6px 8px;height:32px;margin-right:10px;">
  <option value="">Pick a region</option>
  <option value="http://newyork.com">New York</option>
  <option value="http://Philidelphia.com">Philidelphia</option>
  <option value="http://Pittsburg.com">Pittsburg</option>
  <option value="http://TampaBay.com">Tampa Bay</option>
</select>

<a href="javascript:openURL(selURL.value);" class="button">Ok</a>

Open in new window

0
 
yando18Author Commented:
Thanks I will give some of these a shot.
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now