Solved

Link Pages with  <select>?????

Posted on 2000-04-02
4
258 Views
Last Modified: 2010-04-09
Hi
How can I Make a list with links with the <select>-command? My current version:
<select>
<option><a href="URL1">Name</a>
<option><a href="URL2">Name2</a>
...
</select>

It doesn't work. How to do it right?
Thanx
0
Comment
Question by:tiefenauer
  • 2
4 Comments
 
LVL 1

Expert Comment

by:Hardaway
ID: 2677748
Try this,

<select name="select" onChange="location = this.options this.selectedIndex].value;">            <option selected>Select one</option>
<option value="Option2.html">Option 2</option>
<option value="Option3.html">Option 3</option>
.......
</select>

Hope this help.
0
 
LVL 7

Expert Comment

by:nettrom
ID: 2679245
how you solve this depends on whether you want the solution to be run on the client side or the server side.  if it's the latter you'll have to have a submit-button saying "Go!" (or something like that), and then a small form handler that outputs the needed Location-header so the browser gets redirected to the other location.

if you want to do it on the client side, Hardaway's suggestion is one possible solution.  I prefer to do it slightly differently though, using a small function to do the job.  it checks for empty values, making you easily able to have spacers in your code.

script code:

<script type="text/javascript">
function go(mySelect) {
  var myValue = mySelect[mySelect.selectedIndex].value;
  if(myValue != "") {
    location = myValue;
  }
}
</script>

and then use a select like this:

<select onchange="go(this)">
<option value="">Please select your destination</option>
<option value="page1.html">Page #1</option>
<option value="page2.html">Page #2</option>
<option value=""> -- Spacer -- </option>
<option valu="page3.html">Page #3</option>
</select>
0
 
LVL 1

Accepted Solution

by:
Whitewolf earned 10 total points
ID: 2679376
Your code from the beginning is fine, what you need to do is just put the close option tag after each option. Right now, it can't find it and thus won't work.

<option>
<a href="url1">Option1</a>
</option>


Hope this helps,
Whitewolf
0
 
LVL 7

Expert Comment

by:nettrom
ID: 2679426
the closing tag on option elements is optional (pun not intended).  so, the next opening tag for <option> implicitly closes the previous one.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question