apprentice
Members
-
Joined
-
Last visited
Reputation Activity
-
apprentice reacted to Ashley Byrom in Why doesn't this work?I'm probably wrong, I'm no Javascript godfather but from general scripting knowledge I'm thinking there could be a problem with the if statements. Don't you need a semicolon at the end of each line of code? And don't you normally use == instead of = for a comparison? I know you do in lots of other scripting languages... Try this...
function getlink() { var e = document.getElementById("percentage1"); var p = e.options[e.selectedIndex].value; if(p=="10%") { change1("link1","link1.com"); } else if(p=="20%") { change1("link1","link2.com"); } }
I'm presuming that's why you're returning the 20% code every time. You set it to 10% because you only used '=' and then you set it to 20% because you only used '=' so you're not comparing it, you're changing it.