Solved

Link Pages with  <select>?????

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

773 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