Solved

passing a variable to ahref?

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

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. …
This article discusses four methods for overlaying images in a container on a web page
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…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

763 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