PDA

View Full Version : replace a character



cocag
12-14-2009, 05:36 AM
Howdy

how do I replace the a with a b in the image name and assign it to j ?

if i = "../../images/01a.jpg"

Thanks in advance

codeexploiter
12-14-2009, 06:20 AM
var original = "../../images/01a.jpg", j;
var replaceValue = "b";
if(original.indexOf("a.") !== -1){
var j = original.split("a.")[0] + replaceValue + "." + original.split("a.")[1];
}
alert(j)

cocag
12-14-2009, 06:30 AM
Thanks bud ;o))