Solved

passing a variable to ahref?

Posted on 1998-10-05
5
181 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…

856 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