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="javas cript" 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[i].link;
return currentLink;
}
function getPath(i)
{
var currentPath = arrayImages[i].path;
return currentPath;
}
function getWidth(i)
{
var currentWidth = arrayImages[i].width;
return currentWidth;
}
function getHeight(i)
{
var currentHeight = arrayImages[i].height;
return currentHeight;
}
Now, for the HTML...
When I call these four functions through a body onLoad, like this:
<body class="backgrou nd_color"
onLoad="alert(g etLink(1));aler t(getPath(1));a lert(getWidth(1 ));alert(getHei ght(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="javascrip t:getLink(1);" target="_blank" ><img
src="javascript :getPath(1);" width="javascri pt:getWidth(1); "
height="javascr ipt: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="javas cript" 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[i].link;
return currentLink;
}
function getPath(i)
{
var currentPath = arrayImages[i].path;
return currentPath;
}
function getWidth(i)
{
var currentWidth = arrayImages[i].width;
return currentWidth;
}
function getHeight(i)
{
var currentHeight = arrayImages[i].height;
return currentHeight;
}
Now, for the HTML...
When I call these four functions through a body onLoad, like this:
<body class="backgrou nd_color"
onLoad="alert(g etLink(1));aler t(getPath(1));a lert(getWidth(1 ));alert(getHei ght(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="javascrip t:getLink(1);" target="_blank" ><img
src="javascript :getPath(1);" width="javascri pt:getWidth(1); "
height="javascr ipt:getHeight(1 );" border="0"><br> LARGER IMAGE</a>
Is this possible? Is there a workaround for this? Any help would be
VERY appreciated!!
Comment