Jump to content

Including an <a> Element within a <select> Element


AndrewAK

Recommended Posts

I'm experiencing "code-lock" :) Is it even possible to put an <a> element within an <option> element that is a part of a <select> element?As far as I can work the logic, it would look somthing like the following code:

<select id="somename"><option><a href="some url">Some Text</a></option></select>

I've tried to get this to work and can't make it happen.Am I missing somthing?I have read about XHTML/HTML Events like "onclick" but can't remember how to use it to load a file from a known location.I should explain myself further. The ultimate goal here is to load a PDF file into the browser with a link that is within the <select> element.

Link to comment
Share on other sites

Option elements can't have child elements, only text. If you want to have a select element that goes to a file on change you can put the URL into the value of the option and write it like this:<select onchange="window.location.href=this.value"><option value="file1.pdf">file 1</option><option value="file2.pdf">file 2</option></select>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...