Adding Hyperlink to combo box in html

Status
Not open for further replies.

bukaida

In the zone
I am trying to create a combo box, with pull-down items, whereby each entry is a hyperlink to a specified file. Can this be done using only html and does anyone know how to do it? If not, should I be tackling this in a different way?
 

QwertyManiac

Commander in Chief
I can only tell a way through simple javascript:
Code:
[noparse]<html>
<head>
<script type="text/javascript">
function urlopen(target)
  {
  window.open(target)
  }
</script>
</head>
<body>

<p ALIGN=Center>
     <center>
          <h1>Example of Form with a Combo Box Hyperlinked using JS</h1>
     </center>
</p>
<form>
     <p>Choose?
          <select NAME="Choose">
               <option VALUE="ABC" onclick="urlopen('*www.google.com')">Google</option>
               <option VALUE="DEF" onclick="urlopen('*www.yahoo.com')">Yahoo</option>
               <option VALUE="WHATEVER" onclick="[/noparse][b]urlopen('pagename.html')[/b][noparse]">FILE</option>
          </select>
     </p>
</form>

</body>
</html>[/noparse]
Unfortunately, this opens the target in a new window but you should do well if you can close the parent window.
 
OP
bukaida

bukaida

In the zone
I am using this script--

Code:
<script type="text/javascript"> 
function go() 
{ 
window.location=document.getElementById("menu").value 
} 
</script>
----------------
and in html body

<select id="menu" onchange="go()"> 
<option>Select Year</option>
<option value="display/und_const.html">2007</option>
<option value="display/und_const.html">2006</option>

--------------------
But the problem is that it is not having the link colour as normal hyperlink.So it is not being possible to identify whether a link is visited or not.
 

QwertyManiac

Commander in Chief
Oh no, that's not the way it works out I think. They (The elements) can trigger a link via the script but aren't exactly hyper-linked in itself. That doesn't seem possible with just basic JS/HTML. There might be ways with x/D/w/eHTML but I don't know of them.
 
Status
Not open for further replies.
Top