Skip to content
Advertisement

javascript dropdown menu onclick

I’ve been working at this for a while now, but don’t understand what’s wrong with my code. I’m sure it’s something simple – it always is!

Basically, I have a drop down menu, with some options. I want it to go to a web page when the third option, plumber, is selected. When any of the others are clicked, nothing should happen.

My code so far is:

JavaScript

Go

And my javascript is:

JavaScript

But it’s not working. Could someone tell me what’s wrong?

Thanks.

C.

Advertisement

Answer

You can either put a change event on your control via script or add it directly to your control..

Direct Method:

JavaScript

This is the function you need to put in your Script:

JavaScript

Add Change event using Script (either JavaScript or JQuery):

I suggest JQuery for doing so (the onSelectedIndexChange function is obsolete here)

JavaScript

If you don’t want to use JQuery just add the following code:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement