...

View Full Version : Dynamic Hyperlink



Chester
09-26-2003, 03:17 PM
I have a form with a drop down list box containing years, (ex. 2003, 2004, etc.) I have a hyperlink that needs to pass the year that the user clicked from the drop down box. How can I do this?

A1ien51
09-26-2003, 03:25 PM
<script>
function GotoPage(theUrl){
var sel = document.theForm.theDropDown;
var txt = sel.options[sel.selectedIndex].text;
window.location.href= theUrl + "?theYear=" + txt;
}
</script>

Chester
09-26-2003, 03:48 PM
Thanks A1ien51, but how do I call this function? Is it done in the href statement?

A1ien51
09-26-2003, 04:19 PM
easiest way

href="javascript:GotoPage('theurl.htm')"

liorean
09-26-2003, 04:21 PM
<a href="choseyearmanually.html" onclick="GotoPage('blah');return false;">

Chester
09-26-2003, 04:31 PM
Thanks-a-million!!!

oracleguy
09-26-2003, 06:30 PM
Just make sure you actually make a "chooseyearmanually.html" in case the user doesn't have javascript enabled.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum