|
I need to put the image name that was given in img tag into a form,or display it on the screen,help me please
|
|
|
Functions:
function GetBaseName(file)
{
var Parts = file.split('\\');
if( Parts.length < 2 )Parts = file.split('/index.html');
return Parts[ Parts.length -1 ];
}
function getE(ID)
{
return document.getElementById(ID);
}
function getImgName(id, opt)
{
img=getE(id);
names=(opt==1)?GetBaseName(img.src):img.src;
return names;
}
function showname(id, todiv, opt)
{
divs=getE(todiv);
names=getImgName(id, opt);
divs.innerHTML=names;
}
</script>
|
|
HTML
<img src="/images/b.png" id="imgs">
<div id="showfull"></div>
<div id="showbase"></div>
<script>
showname("imgs", "showfull", 0); // show full name
showname("imgs", "showbase", 1); // show base name
</script>
|
|
|
|
|
|
|
Don't mind! Your're welcome!
|
|
|
|
|
|
|
// |