AIUTO: come passare una variabile php ad una funzione javascript

beccaccia

Nuovo Utente
25 Giu 2013
1
0
0
Salve a tutti,
potreste aiutarmi a risolvere il seguente problema? :
la seguente funzione javascript mi permette di fare una slideshow a tutto schermo, io vorrei poter passare le url delle foto tramite una variabile php la quale viene a sua volta assegnata tramite il database.


Codice:
<!-- Supersized javascript sources -->
	<script src="sliders_sources/supersized/js/supersized.3.2.6.min.js" type="text/javascript"></script>
    <script src="sliders_sources/supersized/theme/supersized.shutter.min.js" type="text/javascript"></script>
    <script src="sliders_sources/supersized/js/jquery.clip-animation.min.js" type="text/javascript"></script>
    <script type="text/javascript">
		jQuery(function($){
			$.supersized({ 
				//Functionality
				slideshow               :   1,		//Slideshow on/off
				autoplay				:	1,		//Slideshow starts playing automatically
				start_slide             :   1,		//Start slide (0 is random)
				random					: 	0,		//Randomize slide order (Ignores start slide)
				slide_interval          :   9000,	//Length between transitions
				transition              :   1, 		//0-None, 1-Fade, 2-Slide Top, 3-Slide Right, 4-Slide Bottom, 5-Slide Left, 6-Carousel Right, 7-Carousel Left
				transition_speed		:	500,	//Speed of transition
				new_window				:	1,		//Image links open in new window/tab
				pause_hover             :   0,		//Pause slideshow on hover
				keyboard_nav            :   1,		//Keyboard navigation on/off
				performance				:	1,		//0-Normal, 1-Hybrid speed/quality, 2-Optimizes image quality, 3-Optimizes transition speed // (Only works for Firefox/IE, not Webkit)
				image_protect			:	1,		//Disables image dragging and right click with Javascript
				stop_loop				:	0,		//Pauses slideshow upon reaching the last slide.

				//Size & Position
				min_width		        :   0,		//Min width allowed (in pixels)
				min_height		        :   0,		//Min height allowed (in pixels)
				vertical_center         :   1,		//Vertically center background
				horizontal_center       :   1,		//Horizontally center background
				fit_portrait         	:   1,		//Portrait images will not exceed browser height
				fit_landscape			:   0,		//Landscape images will not exceed browser width
				fit_always				:	0,		//Prevents the image from ever being cropped. Ignores minimum width and height.

				//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)
				thumb_links				:	1,		//Generates a list of thumb links that jump to the corresponding slide. If the 'thumb' field for the slide is empty, it will simply scale down the full size image, which can slow performance.
				thumbnail_navigation	:	0,		//Toggles forward/backward thumbnail navigation. When on, thumbnails from the next/previous posts are generated and can be clicked to navigate. If the 'thumb' field for the slide is empty, it will simply scale down the full size image
				slides 					:  	[		//Slideshow Images
		
		// slide 1
			{image : [COLOR="#FF0000"]"http://forum.mrwebmaster.it/images/slides/supersized/slide1.jpg"[/COLOR], 													// main image
			title1 : "LOREM IPSUM DOLOR", 																		// First title - bigger
			title2 : "AENEAN DIGNISSIM JUSTO", 																	// Second title
			align : "top-left",																					// Where to align? - top-left, top-right, center-left, center-right, bottom-left, bottom-right
			thumb : "php_helpers/timthumb.php?src=images/slides/supersized/slide1.jpg&amp;w=150&amp;h=108",		// replace src=....... value with the image.
			url : ""}, 
		// slide 2
			{image : "http://forum.mrwebmaster.it/images/slides/supersized/slide2.jpg", 
			title1 : "CONSECTETUR ADIPISCING ELIT", 
			title2 : "SOCIIS NATOQUE PENATIBUS", 
			align : "top-right",
			thumb : "php_helpers/timthumb.php?src=images/slides/supersized/slide2.jpg&amp;w=150&amp;h=108", 
			url : ""}, 
		// slide 3
			{image : "http://forum.mrwebmaster.it/images/slides/supersized/slide3.jpg", 
			title1 : "LOREM IPSUM DOLOR", 
			title2 : "AENEAN DIGNISSIM JUSTO", 
			align : "center-left",
			thumb : "php_helpers/timthumb.php?src=images/slides/supersized/slide3.jpg&amp;w=150&amp;h=108", 
			url : ""}, 
		// slide 4
			{image : "http://forum.mrwebmaster.it/images/slides/supersized/slide4.jpg", 
			title1 : "CONSECTETUR ADIPISCING ELIT", 
			title2 : "SOCIIS NATOQUE PENATIBUS", 
			align : "center-right",
			thumb : "php_helpers/timthumb.php?src=images/slides/supersized/slide4.jpg&amp;w=150&amp;h=108", 
			url : ""}
			
		], 
			progress_bar:1, // display progress bar
			mouse_scrub:0 });
			
			var $sbh = $("#slideshow .thebottom").height();
			
			$("#controls-wrapper").css({"bottom":$sbh+20});
			$("#progress-back").css({"bottom":$sbh});
			$("#thumb-tray").css({"bottom":$sbh});
		});
	</script><!-- end supersized script -->
 
Ultima modifica di un moderatore:
ciao
da mettere a punto, però potresti provare una cosa del genere

Codice:
//....
<?php
		// slide
while($riga=mysql_fetch_array($query)){
echo <<< SLIDE
			{image : "http://forum.mrwebmaster.it/images/slides/supersized/$riga['slide']",
			title1 : "$riga['title1']", 																		
			title2 : "$riga['title12']",
			align : "top-left",
			thumb : "php_helpers/timthumb.php?src=images/slides/supersized/$riga['slide']&amp;w=150&amp;h=108",
			url : ""},
SLIDE;
}
?>
		],
//ecc...........

il dubbio è che forse sull'ultima slide devi togliere l'ultima virgola
 

Discussioni simili