how to remove last comma ‘ , ‘ with jquery. Below is my code jquery for slideshow image background ,php code will loop image url in javascript, mean user can change image in admin :
navigation : 1, //Slideshow controls on/off
thumbnail_navigation : 1, //Thumbnail navigation
slide_counter : 1, //Display slide numbers
slide_captions : 1, //Slide caption (Pull from "title" in slides array)
slides : [ //Slideshow Images
<?php // this will looping image background custom - xx_rusly_xx
$images = getFieldOrder('background_slideshow_image');
foreach($images as $image){
echo "{image : '";
echo get('background_slideshow_image',1,$image);
echo "'},";
}
?>
]
});
});
</script>
If u see i put some php code for loop image url
<?php // this will looping image background custom - xx_rusly_xx
$images = getFieldOrder('background_slideshow_image');
foreach($images as $image){
echo "{image : '";
echo get('background_slideshow_image',1,$image);
echo "'},";
}
?>
and browser will generate javascript with php like this :
//Components
navigation : 1, //Slideshow controls on/off
thumbnail_navigation : 1, //Thumbnail navigation
slide_counter : 1, //Display slide numbers
slide_captions : 1, //Slide caption (Pull from "title" in slides array)
slides : [ //Slideshow Images
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/1.jpg'},
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/2.jpg'},
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/3.jpg'},
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/4.jpg'}, ]
});
});
</script>
and the problem is how to remove comma in last line, because with internet explorer this will not run except i remove the last comma.
{image : 'http://iconcept-project.com/dev/gd/wp-content/files_mf/4.jpg'},
here is full code –> http://pastebin.com/c1A7ZKGr
thanks for help.
I’m curious. Why don’t you do that in PHP side?