...

View Full Version : Help with Images



feras_wilson
07-07-2006, 02:18 PM
Hi all!
I have some images in a layer which is contenteditable and a dropdown. when i add a image, images name add to the dropdown. I need to know how to when i delete the images, images name remove/delete from the drop down!
I need the code which remove the image name from the dropdown!
Can some one help me?

vwphillips
07-07-2006, 07:25 PM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
<title></title>

<script language="JavaScript" type="text/javascript">
/*<![CDATA[*/

var zxcImgPath='http://www.vicsjavascripts.org.uk/StdImages/';

function zxcAddImg(zxcaid,zxcrid,zxctid){
var zxcaobj=document.getElementById(zxcaid);
var zxcrobj=document.getElementById(zxcrid);
var zxctobj=document.getElementById(zxctid);
if (!window['zxcAddAry'+zxcaobj.id]){
window['zxcAddAry'+zxcaobj.id]=[];
var zxcary=window['zxcAddAry'+zxcaobj.id];
for (var zxc0=1;zxc0<zxcaobj.options.length;zxc0++){
zxcary.push([true,zxcaobj.options[zxc0].text,zxcaobj.options[zxc0].value]);
}
}
if (zxcaobj.value!='xxxxx'){
var zxcimg=zxcStyle('IMG',{width:'100px',height:'100px'});
zxcimg.src=zxcImgPath+zxcaobj.value;
zxctobj.appendChild(zxcimg);
}
var zxcary=window['zxcAddAry'+zxcaobj.id];
var zxcimgs=zxctobj.getElementsByTagName('IMG');
for (var zxc0=0;zxc0<zxcary.length;zxc0++){
zxcary[zxc0][0]=true;
for (var zxc1=0;zxc1<zxcimgs.length;zxc1++){
if (zxcimgs[zxc1].src.match(zxcary[zxc0][2])){
zxcary[zxc0][0]=false;
}
}
}
zxcPopulate(zxcaobj,zxcrobj,zxcary);
}

function zxcRemoveImg(zxcaid,zxcrid,zxctid){
var zxcaobj=document.getElementById(zxcaid);
var zxcrobj=document.getElementById(zxcrid);
var zxctobj=document.getElementById(zxctid);
var zxcary=window['zxcAddAry'+zxcaobj.id];
var zxcimgs=zxctobj.getElementsByTagName('IMG');
for (var zxc1=0;zxc1<zxcimgs.length;zxc1++){
if (zxcimgs[zxc1].src.match(zxcrobj.value)){
zxctobj.removeChild(zxcimgs[zxc1]);
}
}
for (var zxc2=0;zxc2<zxcary.length;zxc2++){
if (zxcrobj.value==zxcary[zxc2][2]){
zxcary[zxc2][0]=true;
}
}
zxcPopulate(zxcaobj,zxcrobj,zxcary);
}

function zxcPopulate(zxcaobj,zxcrobj,zxcary){
zxcaobj.options.length=1;
zxcrobj.options.length=1;
for (var zxc2=0;zxc2<zxcary.length;zxc2++){
if (zxcary[zxc2][0]){ zxcaobj.options[zxcaobj.options.length]=new Option(zxcary[zxc2][1],zxcary[zxc2][2],true,true); }
else { zxcrobj.options[zxcrobj.options.length]=new Option(zxcary[zxc2][1],zxcary[zxc2][2],true,true); }
}
zxcaobj.selectedIndex=0;
zxcrobj.selectedIndex=0;
}

function zxcStyle(zxcele,zxcstyle,zxctxt){
if (typeof(zxcele)=='string'){ zxcele=document.createElement(zxcele); }
for (key in zxcstyle){ zxcele.style[key]=zxcstyle[key]; }
if (zxctxt){ zxcele.appendChild(document.createTextNode(zxctxt)); }
return zxcele;
}


/*]]>*/
</script>
</head>

<body>
<select id="Add" onchange="zxcAddImg('Add','Remove','Target');" >
<option value="xxxxx" >Add Image</option>
<option value="One.gif" >Image One</option>
<option value="Two.gif" >Image Two</option>
<option value="Three.gif" >Image Three</option>
</select>
<select id="Remove" onchange="zxcRemoveImg('Add','Remove','Target');" >
<option value="xxxxx" >Remove Image</option>
</select>
<div id="Target" ></div>

</body>

</html>

feras_wilson
07-07-2006, 10:10 PM
I mean when i press delete key, it remove.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum