I want to set a value for dropdown list by clicking a link, i tried something like this, but it isn't working :
<html>
<body>
<select id="select">
<option value="one">one</option>
<option value="two">Two</option>
<option value="three">Three</option>
</select><br />
<a class="link1" value="two" href="page.php?cc=two">Two</a><br /><br />
<a class="link1" value="three" href="page.php?cc=three">Three</a>
<script>
function setSelect () {
var elmnt = document.getElementsByClassName('link1');
for (i = 0; i < elmnt.length; i++) {
elmnt[i].onclick = function () {
document.getElementById('select').value = elmnt[i].getAttribute("value");
window.history.pushState('Form', 'My form', this.getAttribute("href"));
return false;
};
}
}
setSelect ();
</script>
</body>
</html>
I also tried getting a value from the URL into the dropdown list by clicking the link, it didn't work, so i'm trying to set the drop downlist with the link value.
Any help would be much appreciated.