I have a user input form with multiple drop downs that display based on user selection. When a user selects an option from the 2nd drop down I would like to append that selection to a url.
Here's what I am working with: http://jsfiddle.net/Sxz4R/142/
Here's the JS in question:
function changeText2(){
var userInput = document.getElementById('userInput').value;
var lnk = document.getElementById('lnk');
lnk.href = "http://google.com/?q=" + encodeURIComponent(userInput);
lnk.innerHTML = lnk.href;
The issue is once the link is set it will not change again if a different option is selected from the first drop down menu.
Repro:
1) Select List of Colors
2) Select a color -- Link will change
Without refreshing...
1) Select "List of Numbers" from drop down
2) Select a number -- Link does not change
How do I get the link to change if the user decides to select a new option from the first menu?