Ver Mensaje Individual
  #8 (permalink)  
Antiguo 09/04/2012, 12:21
Maru77
 
Fecha de Ingreso: agosto-2003
Mensajes: 524
Antigüedad: 20 años, 8 meses
Puntos: 5
Respuesta: Cómo pasar de php a array de javascript

gjx2, gracias por tu inmensa paciencia!

Probé el código de tu ejemplo y funciona!

Solo que cuando lo adapto al mio agregando titulo y link además de la imagen no funciona.

Te dejo el código completo:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>

<link href='http://fonts.googleapis.com/css?family=Cabin+Condensed' rel='stylesheet' type='text/css'>


<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>
<script type="text/javascript" src="js/simplegallery.js"></script>

<?php


$conn = new conection();
$rs = new RecordSet($conn);

$sql="SELECT * FROM `banners` ORDER BY `id` DESC LIMIT 5";
$banners = $rs->get_object_list($sql);

foreach($banners as $ban){
$img[]="imagenes/banners/$ban->id/n0-s0.jpg";
$tit[]="$ban->titulo";

}

?>
<script type="text/javascript">
window.onload = function(){

var img = new Array();
var tit = new Array();

var imagenes = <?=json_encode($img)?>
var titulos = <?=json_encode($tit)?>


for(i=0;i<imagenes.length;i++){

img[i] = new Array(imagenes[i],"","","","");
tit[i] = new Array(titulos[i],"","","","");
}

var mygallery=new simpleGallery({
wrapperid: "simplegallery", //ID of main gallery container,
dimensions: [1280, 510], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
imagearray: [img, tit],
autoplay: [true, 2500, 2], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
oninit:function(){ //event that fires when gallery has initialized/ ready to run
//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
},
onslide:function(curslide, i){ //event that fires after each slide is shown
//Keyword "this": references current gallery instance
//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
}
})

}

</script>

</head>

<body>

<div id="simplegallery"></div>

</body>
__________________
Saludos!!!
Maru.-