E
elsenraat_76
Hello! I was wondering if someone could help me out with a problem I'm
having? I'm trying to input a javascript value into an anchor tag
(from a function), but don't have an event to call the function...if
that makes sense. Here's what I mean...
I have a javascript array set up like so:
<script language="javascript" TYPE="text/JavaScript">
//custom object constructor
function theImage(path, width, height, link)
{
this.path = path;
this.width = width;
this.height = height;
this.link = link;
}
var arrayImages = new Array()
arrayImages[0] = new theImage("/somelink_a.jpg", "216", "302",
"/somelink_b.jpg");
arrayImages[1] = new theImage(/anotherimage_a.jpg", "216", "302",
"/anotherimage_b.jpg");
etc, etc...
And I have the following javascript functions...
function getLink(i)
{
var currentLink = arrayImages.link;
return currentLink;
}
function getPath(i)
{
var currentPath = arrayImages.path;
return currentPath;
}
function getWidth(i)
{
var currentWidth = arrayImages.width;
return currentWidth;
}
function getHeight(i)
{
var currentHeight = arrayImages.height;
return currentHeight;
}
Now, for the HTML...
When I call these four functions through a body onLoad, like this:
<body class="background_color"
onLoad="alert(getLink(1));alert(getPath(1));alert(getWidth(1));alert(getHeight(1));">
the values '/anotherimage_a.jpg"', '216', '302', '/anotherimage_b.jpg'
are returned in the alert. But, I would like to have these values
returned in an anchor tage like so...
<a href="javascript:getLink(1);" target="_blank"><img
src="javascript:getPath(1);" width="javascript:getWidth(1);"
height="javascript:getHeight(1);" border="0"><br>LARGER IMAGE</a>
Is this possible? Is there a workaround for this? Any help would be
VERY appreciated!!
having? I'm trying to input a javascript value into an anchor tag
(from a function), but don't have an event to call the function...if
that makes sense. Here's what I mean...
I have a javascript array set up like so:
<script language="javascript" TYPE="text/JavaScript">
//custom object constructor
function theImage(path, width, height, link)
{
this.path = path;
this.width = width;
this.height = height;
this.link = link;
}
var arrayImages = new Array()
arrayImages[0] = new theImage("/somelink_a.jpg", "216", "302",
"/somelink_b.jpg");
arrayImages[1] = new theImage(/anotherimage_a.jpg", "216", "302",
"/anotherimage_b.jpg");
etc, etc...
And I have the following javascript functions...
function getLink(i)
{
var currentLink = arrayImages.link;
return currentLink;
}
function getPath(i)
{
var currentPath = arrayImages.path;
return currentPath;
}
function getWidth(i)
{
var currentWidth = arrayImages.width;
return currentWidth;
}
function getHeight(i)
{
var currentHeight = arrayImages.height;
return currentHeight;
}
Now, for the HTML...
When I call these four functions through a body onLoad, like this:
<body class="background_color"
onLoad="alert(getLink(1));alert(getPath(1));alert(getWidth(1));alert(getHeight(1));">
the values '/anotherimage_a.jpg"', '216', '302', '/anotherimage_b.jpg'
are returned in the alert. But, I would like to have these values
returned in an anchor tage like so...
<a href="javascript:getLink(1);" target="_blank"><img
src="javascript:getPath(1);" width="javascript:getWidth(1);"
height="javascript:getHeight(1);" border="0"><br>LARGER IMAGE</a>
Is this possible? Is there a workaround for this? Any help would be
VERY appreciated!!