Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder feras_wilson's Avatar
    Join Date
    Jul 2005
    Location
    Sweden
    Posts
    129
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation Help with Images

    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?
    Last edited by feras_wilson; 07-07-2006 at 03:12 PM.
    Exp:
    PHP
    .NET

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,466
    Thanks
    3
    Thanked 495 Times in 482 Posts
    Code:
    <!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>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    Regular Coder feras_wilson's Avatar
    Join Date
    Jul 2005
    Location
    Sweden
    Posts
    129
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Delete event

    I mean when i press delete key, it remove.
    Exp:
    PHP
    .NET


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •