JavaScript:Set File Extension according to Files in folder -
i new in javascript doing image pagination,
function changedata(img) { image = document.getelementbyid('image'); var imagepath="images/"+img+".jpg"; image.src = imagepath; }
here in changedata(img) passing image name , concatenate name image extension , set img src,
here 1 thing should keep in mind images copy , paste in images folder image name in sequence number 1,2,3,4.....etc
here did concatenation .jpg if 1 place images .png, .bmp, .gif create problem here how can .png, .bmp, .gif can 1 suggest me? please...
1.you pass extension variable function. 2.another way convert pictures .jpg. 3.(this worst way) since know format of each picture, can write this:
{ **var ext=".jpg"; if(img=="4"){ext=".png"} else if ...** image = document.getelementbyid('image'); var imagepath="images/"+img+**ext;** image.src = imagepath; }
Comments
Post a Comment