javascript - Converting JS output to PHP variable -


here code using... (javascript injection)


date.prototype.getweek = function() {   var onejan = new date(this.getfullyear(),0,1);   return math.ceil((((this - onejan) / 86400000) + onejan.getday()+1)/7); } var imglist = [   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',   'img/1.jpg',  'img/1.jpg'   // note: no comma after last entry ];  function showimage() {   var today = new date();   var weekno = today.getweek();   document.getelementbyid('weeklyimage').src = imglist[weekno];   document.getelementbyid('weeklyimage').alt = imglist[weekno]; //  alert(weekno+'\t'+imglist[weekno]); } 

i wondering if can tell me how convert image src php variable $weeklyimage or can following...


echo "<img src='" . $weeklyimage . "'>"; 

i need output in php can use variable other areas of site require php functions.

if not possible, other suggestions appreciated.

thanks!

it impossible directly pass values javascript php, because php runs on server, result of php script sent client, , javascript run.

for problem, there absolutely no need use javascript @ all. can current week date('w') , store entire list of images in simple array:

$images = ['image1.jpg', 'image2.jpg'...]; echo '<img src="'.$images[date('w')].'">'; 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -