Results 1 to 3 of 3

Thread: I want with one command become lowercase images containers

  1. #1
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default I want with one command become lowercase images containers

    I have many images from 1 to 33, letters of russian alphabet and I want with one command become lowercase(/image2/XX.png) from uppercase(/images/XX.png) ... I tried but meet rather concenation...
    Code:
          <tr>
            <td id="cell61"><img src="images/30.png" alt="30" height="69" width="69" id="p30" /></td>
            <td id="cell62"><img src="images/31.png" alt="31" height="69" width="69" id="p31" /></td>
            <td id="cell63"><img src="images/32.png" alt="32" height="69" width="69" id="p32" /></td>
            <td id="cell64"><img src="images/33.png" alt="33" height="69" width="69" id="p33" /></td>
    
    function lower() {
    	  
      for (var i=0; i<33; i++) {   // replace images/  with image2/  // folder is, img names are the same
    	  var j=i+1
    	  var xsrc=document.getElementById("p"+j).src;
    	  var newsrc=xsrc.replace(xsrc.slice(-13,6), "image2");  
    	  document.getElementById("p"+j).src=newsrc;
      }  	  
      alert(newsrc); 
    }
    Last edited by leonidassavvides; 04-08-2010 at 06:44 PM.

  2. #2
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Default

    You need the following code for replacing a substring in a string

    Code:
    img.src = img.src.replace(/images/, "image2");
    Asssuming that img is an image element.

    Hope this helps

  3. #3
    Join Date
    Oct 2004
    Posts
    425
    Thanks
    4
    Thanked 1 Time in 1 Post

    Default

    what if /images/ can take ONLY the values images, image1, image2...???

Bookmarks

Posting Permissions

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