views:

48

answers:

3

I want to make a little gallery and add next/previous buttons. I managed to trim down the urls of the pictures to something like this : 30052010/30052010001 . So the picture is 30052010001.jpg and the next one is 30052010002.jpg .However how can i remove the first part of the string(the folder name) and the last digits from the end of the string so that i can auto-increment a variable and change to the next picture ? Thanks.

+2  A: 

You can use split function

PerlDev
+3  A: 

You can do it with only Javascript like this:

var x = "30052010/30052010001";
y = x.split('/');
alert(y[1]+'.jpg');
Bogdan Constantinescu
ok ill give it a try :D uu roman // perfect !
andrei
+2  A: 
var filename = '30052010/30052010001';
var parts = filename.split('/');
var newFilename= (parts[0] + "/" + ++ (parts[1])); // '30052010/30052010002'
Erin Stanfill