Solved

Link Pages with  <select>?????

Posted on 2000-04-02
4
225 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Summernote and form validation 10 42
Hover Gone 16 31
Help with HTML 7 39
HTML page and JavaScript 2 52
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
This article discusses how to create an extensible mechanism for linked drop downs.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
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…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now