Solved

passing a variable to ahref?

Posted on 1998-10-05
5
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

718 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