Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<img src="c:users\xxxxx\xxxx\________"/>
i want to give the value for the blank line through javascript. let the value be xxxx.jpg.
var a=xxxx.jpg.

how to use the "var a" inside the src url so that i can get the image
Posted

XML
<body onload=""setImageSrc();"><br" mode="hold" /><img id="img1" src="c:users\xxxxx\xxxx\________"/>
</body


XML
<script language="javascript">
function setImageSrc()
{
var img1=document.getElementById('img1');
img1.src='a.jpg';
}
</script>
 
Share this answer
 
You can write the script as:

C#
function LoadImages() {
    searchPic = new Image();
    searchPic.onload=function () {
        document["pic1"].src = "XXXX/YYYY/search.png";
    }
    searchPic.src = "XXXX/YYYY/search.png";
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900