Link to home
Start Free TrialLog in
Avatar of sirichaiphumirat
sirichaiphumiratFlag for United States of America

asked on

HTML and Javascript issue: How to loop and change the file names

How can I do a loop and change file names a long with it.   I have the current code that works if i want to loop and print out the img src line 10 types.

But i am unsure of how to loop through, and print out the img src and change the file name as well.

For example first loop would print out

img src="http://test.co/media/img/1.png
next loop will print out
img src="http://test.co/media/img/2.png
next loop will print out
img src="http://test.co/media/img/3.png
and so on un till  img src="http://test.co/media/img/10.png

my guess would be  something like this    img src="http://test.co/media/img/" + HTMLstring[i] + ".png"
but it doesn't seem to work. Or i can be totally off.   Thanks for any help in advance.

var HTMLstring = "";
            for(var i = 0; i < 10; i++){
                HTMLstring += '<img src="http://test.co/media/img/1.png">'
            }
ASKER CERTIFIED SOLUTION
Avatar of Leonidas Dosas
Leonidas Dosas
Flag of Greece image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sirichaiphumirat

ASKER

ahhh thank you very much!!!