PDA

View Full Version : I want with one command become lowercase images containers



leonidassavvides
04-08-2010, 06:28 PM
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...
<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);
}

codeexploiter
04-09-2010, 10:16 AM
You need the following code for replacing a substring in a string


img.src = img.src.replace(/images/, "image2");

Asssuming that img is an image element.

Hope this helps

leonidassavvides
04-09-2010, 01:18 PM
what if /images/ can take ONLY the values images, image1, image2...???