Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Form dropdown field equates to a hyperlink

Hi guys!

I'm trying to get a form dropdown field to send people to a webpage once they select an option. I'm using a bit of javascript at the moment but it's causing everything the bootstrap tabs I'm using to break in IE8 (sad that I have to support it I know).

This is the code I'm using at the moment -

Dropdown - option value="Link here">Dentist</option

Javascript -

<script type="text/javascript">
var urlmenu = document.getElementById( 'find' );
urlmenu.onchange = function() {
window.open( this.options[ this.selectedIndex ].value );
};
</script>

Is there are different way to do this to achieve the same effect without breaking IE8? I don't mind what langauge is being use, php etc

Thanks in advance! Liam

2 Answers

Hi Liam Hawkes

Funnily enough I was messing about with something similar today; my code was as follows:

<select id="myIDname" onchange="document.location.href=this.value">
<option value="http://google.com">My link text</option>
</select>

See if that works?

Perfect, thanks Caroline Murphy!!

No probs Liam!