Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-26-2003, 02:17 PM   PM User | #1
Chester
New Coder

 
Join Date: May 2003
Location: New Jersey
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Chester is an unknown quantity at this point
Dynamic Hyperlink

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?
Chester is offline   Reply With Quote
Old 09-26-2003, 02:25 PM   PM User | #2
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
Code:
<script>
  function GotoPage(theUrl){
    var sel = document.theForm.theDropDown;
    var txt = sel.options[sel.selectedIndex].text;
    window.location.href= theUrl + "?theYear=" + txt;
  } 
</script>
A1ien51 is offline   Reply With Quote
Old 09-26-2003, 02:48 PM   PM User | #3
Chester
New Coder

 
Join Date: May 2003
Location: New Jersey
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Chester is an unknown quantity at this point
Thanks A1ien51, but how do I call this function? Is it done in the href statement?
Chester is offline   Reply With Quote
Old 09-26-2003, 03:19 PM   PM User | #4
A1ien51
Senior Coder

 
A1ien51's Avatar
 
Join Date: Jun 2002
Location: Between DC and Baltimore In a Cave
Posts: 2,717
Thanks: 1
Thanked 94 Times in 88 Posts
A1ien51 will become famous soon enough
easiest way

href="javascript:GotoPage('theurl.htm')"
A1ien51 is offline   Reply With Quote
Old 09-26-2003, 03:21 PM   PM User | #5
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
<a href="choseyearmanually.html" onclick="GotoPage('blah');return false;">
__________________
liorean <[lio@wg]>
Articles: RegEx evolt wsabstract , Named Arguments
Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards
liorean is offline   Reply With Quote
Old 09-26-2003, 03:31 PM   PM User | #6
Chester
New Coder

 
Join Date: May 2003
Location: New Jersey
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Chester is an unknown quantity at this point
Thanks-a-million!!!
Chester is offline   Reply With Quote
Old 09-26-2003, 05:30 PM   PM User | #7
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,043
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
Just make sure you actually make a "chooseyearmanually.html" in case the user doesn't have javascript enabled.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:41 AM.


Advertisement
Log in to turn off these ads.