Preece
asked on
in img tag, javascript function to get path of image file
As the title implies, I want to call a function, passing a variable or two, that will return the path for a given image file. In the code below:
<blockquote class="black-normal-width3 00">
<p><img id="img10" src="sunsets2/Nov-2004-sun set-1-sm.j pg" title="Click thumbnail for larger image" onclick='JavaScript: togglePic("img10", src="http://www.somedomain.com/pictures/02-2005/Feb-09-2005-sunset-1.jpg"); return false;' alt=""><br><br>November 2004 sunset 1 of 3</p>
</blockquote>
I want this:
src="http://www.somedomain.com/pictures/02-2005/Feb-09-2005-sunset-1.jpg"
to be something like:
src= somefunction(var1, var2) + "/02-2005/Feb-09-2005-suns et-1.jpg"
Thanks in advance,
Preece
<blockquote class="black-normal-width3
<p><img id="img10" src="sunsets2/Nov-2004-sun
</blockquote>
I want this:
src="http://www.somedomain.com/pictures/02-2005/Feb-09-2005-sunset-1.jpg"
to be something like:
src= somefunction(var1, var2) + "/02-2005/Feb-09-2005-suns
Thanks in advance,
Preece
ASKER
Show how it would be placed in this code block:
<blockquote class="black-normal-width3 00">
<p><img id="img10" src="http://www.somedomain.com/pictures/02-2005/022905-1sm.jpg" title="Click thumbnail for larger image" onclick='JavaScript: togglePic("img10", src="http://www.somedomain.com/pictures/02-2005/022905-1.jpg"); return false;' alt=""><br><br>02/29/2005 pic 1 of 3</p>
</blockquote>
<blockquote class="black-normal-width3
<p><img id="img10" src="http://www.somedomain.com/pictures/02-2005/022905-1sm.jpg" title="Click thumbnail for larger image" onclick='JavaScript: togglePic("img10", src="http://www.somedomain.com/pictures/02-2005/022905-1.jpg"); return false;' alt=""><br><br>02/29/2005 pic 1 of 3</p>
</blockquote>
ASKER
I'm ok with this part:
<head>
<script language="javascript">
function callsrc(){
return "https://www.experts-exchange.com/";
}
</script>
</head>
but, how would this:
<script language="javascript1.2">
imgsrc=callsrc();
document.write("<img src='"+imgsrc+"images/cert ification. gif'>");
</script>
be integrated in with:
<p><img id="img10" src="http://www.somedomain.com/pictures/02-2005/022905-1sm.jpg" title="Click thumbnail for larger image" onclick='JavaScript: togglePic("img10", src="http://www.somedomain.com/pictures/02-2005/022905-1.jpg"); return false;' alt=""><br><br>02/29/2005 pic 1 of 3</p>
Thanks,
Preece
<head>
<script language="javascript">
function callsrc(){
return "https://www.experts-exchange.com/";
}
</script>
</head>
but, how would this:
<script language="javascript1.2">
imgsrc=callsrc();
document.write("<img src='"+imgsrc+"images/cert
</script>
be integrated in with:
<p><img id="img10" src="http://www.somedomain.com/pictures/02-2005/022905-1sm.jpg" title="Click thumbnail for larger image" onclick='JavaScript: togglePic("img10", src="http://www.somedomain.com/pictures/02-2005/022905-1.jpg"); return false;' alt=""><br><br>02/29/2005 pic 1 of 3</p>
Thanks,
Preece
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, prsupriya, I'll have a look at this later today...
<head>
<script language="javascript">
function callsrc(){
return "https://www.experts-exchange.com/";
}
</script>
</head>
<body>
<script language="javascript1.2">
imgsrc=callsrc();
document.write("<img src='"+imgsrc+"images/cert
</script>
</body>