Solved

passing a variable to ahref?

Posted on 1998-10-05
5
168 Views
Last Modified: 2010-04-09
I need to have a hyperlink that can be passed a variable which is the result of a javascript that runs when the page is loaded. The link will point to a .gif who's name is dependent on the current date. How can I pass the result of my javascript function to href= so that the link will dynamically update itself?
0
Comment
Question by:rizzok
  • 3
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
nchalasa062698 earned 50 total points
ID: 1838366
At the hyper link call the javascript function and that function can do
   window.location.href="the new url".

and syntax for that hyperlink is,
    <A HREF="javascript:function_name()">text_to_display</A>
0
 

Author Comment

by:rizzok
ID: 1838367
That's what I had in mind but can I pass a variable to where it says "the new url".

you wrote:

At the hyper link call the javascript function and that function can do window.location.href="the new url".  

0
 
LVL 1

Expert Comment

by:nchalasa062698
ID: 1838368
yes , you can.

If you tell me exactly what you want to do , I can write
 the code more clearly.
0
 

Author Comment

by:rizzok
ID: 1838369
My function will result in a variable that contains a filename that changes every Friday at midnight and it's name is made up of the date (eg. 981002.gif).

So, window.location.href="var1" will work, being that var1 (=981002.gif) is the result of my function? With or without ""?
This is all the info I need, then the points are yours!!

0
 
LVL 1

Expert Comment

by:nchalasa062698
ID: 1838370
window.location.href=var1 ( without the codes should work for you.)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now