2 Replies - 16691 Views - Last Post: 21 April 2009 - 05:10 AM

#1 Jakke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-April 09

Valid XHTML Drop down menus without javascript

Posted 18 April 2009 - 05:33 PM

Hi folks
Below I posted the basic code I use on a lot of current pages.
It creates an ordinary old fashioned drop down menu using javascript.
It also is not valid XHTML because of the "name" attribute used, but the javascript does not work without it.
So I was trying to find a way to
1. Do away with the javascript, because of course it does not work if a visitor has javascript disabled
2. Make sure it is valid XHTML
3. But still uses <option value=""></option> because the code with all the options is delivered somehow from another file and I cannot change that (or at least would be too much work).

So I looked various places but cannot find anything that solves my problem. There are plenty of other menus that would do the trick if I would start from scratch, but I need to be able to use <option value=""></option> for the menu.

I hope I am clear enough. Thanks!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript">
function leapto(pulldown) 
   {
   var myindex=pulldown.selectedIndex;
   if (myindex>=0)
	  { top.location=pulldown.options[myindex].value; }
   }
</script>
<title></title>
</head>
<body>
<form id="menu" name="menu" action="java script:leapto(document.menu.dest)">
<p>
 <select name="dest">
  <option value="http://google.com">One</option> 
  <option value="http://yahoo.com">Two</option> 
  <option value="http://msn.com">Three</option> 
  <option value="http://yahoo.com">Four</option>
 </select>
 </p>
<p>
 <input type="submit" name="button" id="button" value="Submit" />
</p>
</form> 
</body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: Valid XHTML Drop down menus without javascript

#2 neit  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 187
  • Joined: 13-February 09

Re: Valid XHTML Drop down menus without javascript

Posted 20 April 2009 - 03:27 PM

Why don't you just create a css drop down menu and skin to your needs.
Have a read of this tutorial.

http://meyerweb.com/...menus/demo.html

There are others on the wbe showing a similar menu
Was This Post Helpful? 0
  • +
  • -

#3 Jakke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 18-April 09

Re: Valid XHTML Drop down menus without javascript

Posted 21 April 2009 - 05:10 AM

View Postneit, on 20 Apr, 2009 - 02:27 PM, said:

Why don't you just create a css drop down menu and skin to your needs.

Because like I said in the original post, I need to be able to use <option value=""></option>.
I have like a hundred pages that have each a different included file that goes like this
<option value="http://something">Some value</option> 
<option value="http://something">Some value</option>
<option value="http://something">Some value</option>
<option value="http://something">Some value</option>
and some of these have more than 30 options.
If I would change to a CSS menu then I need to use <li> tag instead of the <option> tag, and it just is not feasible to change all my pages.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1