Passing Custom Post Field values to javascript

Is it possible to pass Custom Post variables into a javascript file? What I am trying to do is to grab the user-entered URLs of several images to create a gallery slideshow. For example the user:

Enters a URL of an image in a Custom Post Field with the value Image1, then again the user enters a URL of an image in another Custom Post Field with the value Image2.

Read More

The values of image1 and image2 are passed into a javascript file (slideshow) with the following code which basically holds the slides:

images = [‘http://www.hdwallpapersimages.com/wp-content/uploads/2014/01/Winter-Tiger-Wild-Cat-Images.jpg‘, ‘http://3.bp.blogspot.com/-rZmCIp0C-hQ/Tx6aCFeweoI/AAAAAAAAAnQ/WqIEVBTIzRk/s1600/Cool-Tiger-Wallpaper-1920×1080-HD.jpg‘];

What i need is to replace the 2 URL above with 2 variables that actually hold the URL of the images.

Thank you for the reply.

Related posts

1 comment

  1. Why don’t you create your JavaScript dynamically with PHP?
    In that way you can read your $_POST field and create a JS array.
    Else if you can’t write JS with a server side script you can write into a file with the PHP script which read the POST and then read your file with JS.. But in that way anybody can read it!

    Hope it helps and sorry for my English!
    Bye!

Comments are closed.