Hola vuelvo aqui al foro en busqueda de ayuda, ya que no encuentro una solución apropiada a mi script, he intentado de varias maneras hacer un bucle php que me busque en la base de datos el cual si pude hacer pero a la hora de tratar de tomar esta variable en un script de javascript no funciona adecuadamente
Este es el codigo completo de la pagina:
Código:
<html><head>
<title></title>
<? include('admin/archivos-admin/textos-sql.php');?>
<SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Ken Tholke, [email protected]. -->
<!-- Begin
// add as many or as few messages as you would like
var msg=new Array()
<?php
for($vartxt=0; $vartxt<$indtxt; $vartxt++)
{
?>
msg[<?php echo $vartxt; ?>]="<? echo $textosql[$vartxt]; ?>";
<?
}
?>
//msg[0]="<CENTER>Bienvenido.....</CENTER>";
//msg[1]="<CENTER>Aquì estarán todos los anuncios de eventos
importantes</CENTER>";
//msg[2]="<CENTER>Por favor revise periodicamente suy
pagina</CENTER>";
//msg[3]="<CENTER>Cheap Web hosting/Hospedarweb</CENTER>";
// set your first set of colors. Use as many or as few as you wish.
var colors1=new Array("ffffff", "eeeeff", "ddddff", "ccccff",
"bbbbff", "aaaaff", "9999ff",
"8888ff", "7777ff", "6666ff", "5555ff", "4444ff", "3333ff","2222ff",
"1111ff", "0000ff")
//set your second set of colors
// *** must have exactly the same number of colors as the array
above ***
var colors2=new Array("ffffff", "ffeeee", "ffdddd", "ffcccc",
"ffbbbb", "ffaaaa", "ff9999",
"ff8888", "ff7777", "ff6666", "ff5555", "ff4444", "ff3333",
"ff2222", "ff1111", "ff0000")
//set the height of the display in pixels
high="";
//set the width of the display in pixels
wide="";
//set the pixel coordinates for the upper left hand corner of the
display
Xpos="";
Ypos="";
// move the display away from the edges of the background
pad=15;
// set the background color of the display
bgcol="ffffff";
//add a background image if you want.
// *** for no image, just leave empty quotes (ex. cellbg=""; ) ***
cellbg="imagenes/top_001.jpg";
// set the font
fntFam="verdana,helvetica,arial";
fntSize=14;
// set how how many seconds you want the message to stay remain at
totality.
pause=2.5;
// Do not edit these values below!!!
icolor=0;
mcolor=1;
imsg=0;
spWidth=wide-(2*pad);
totality=false;
glowing=true;
var theMsg="";
var cellcontent="";
pause=pause*1000;
if(cellbg.length>4){cellbg=" background="+cellbg}
else{cellbg="";}
function doPause(){
totality=false; t=setTimeout("changecolor()",pause);
}
function initiate(){
getContentColor();
getMsg();
getCellContent();
if(document.all){
msgbg.innerHTML=cellcontent;
msgfade.innerHTML=theMsg;
msgbg.style.posLeft=Xpos;
msgbg.style.posTop=Ypos;
msgfade.style.posLeft=Xpos+pad;
msgfade.style.posTop=Ypos+pad;
t=setTimeout("changecolor()",50);}
if(document.layers){
document.msgbg.document.write(cellcontent);
document.msgbg.document.close();
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
document.msgbg.left=Xpos;
document.msgbg.top=Ypos;
document.msgfade.left=Xpos+pad;
document.msgfade.top=Ypos+pad;
t=setTimeout("changecolor()",100);}
}
function changecolor(){
if(totality==true){doPause();}
else{
getMsg();
getContentColor();
if(document.all){
msgfade.innerHTML=theMsg;
t=setTimeout("changecolor()",50);}
if(document.layers){
document.msgfade.document.write(theMsg);
document.msgfade.document.close();
t=setTimeout("changecolor()",70);}
}
}
function getFadeColor(){
icolor=icolor-1;
if(mcolor==1){contentcolor=colors1[icolor];}
else{contentcolor=colors2[icolor];}
}
function getGlowColor(){
icolor=icolor+1;
if(mcolor==1){contentcolor=colors1[icolor];}
else{contentcolor=colors2[icolor];}
}
function changemsg(){
if(imsg==msg.length-1){imsg=0; mcolor=1;}
else if(imsg != msg.lenght-1 && mcolor==1){imsg=imsg+1;
mcolor=0;}
else{imsg=imsg+1; mcolor=1;}
}
function getContentColor(){
if(icolor==colors1.length-1 && glowing==true){
getFadeColor(); glowing=false; totality=true;}
else if(icolor < colors1.length && glowing==true){
getGlowColor();}
else if(icolor < 1 && glowing==false){changemsg();
getGlowColor(); glowing=true;}
else{getFadeColor();}
}
function getMsg() {
theMsg="<span style='font-size:"+fntSize+"pt;
font-family:"+fntFam+"; width:"+spWidth+";'>"
theMsg+="<B><font color="+contentcolor+">"+msg[imsg]+"</font></B>
"
theMsg+="</span>"
}
function getCellContent(){
cellcontent="<TABLE height="+high+
" width="+wide+" bgcolor="+bgcol+" cellpadding=0
cellspacing=0><TR><TD"+cellbg+"> </TD></TR></TABLE>"}
// End -->
</script>
</head><body onLoad="initiate()"><div align=center>
<table bordercolor=navy border=2 width=990 height=160 background="<?
echo 'admin/'.$cltpath[0] ?>"><tr><td>
<DIV id=msgbg></DIV>
<DIV id=msgfade></DIV>
</td></tr></table></div>
</body></html>
y el archivo incuido textos-sql.php
Código PHP:
<?php
include('config-sql.php');
$tabla2 = mysql_query("SELECT * FROM datos Where posicion='centro'");
$indtxt = 0;
$textosql = array( );
$cltposicion = array( );
while ($registro = mysql_fetch_array($tabla2)) {
$indtxt = $indtxt + 1;
array_push($textosql, $registro["textos"]);
} // fin del bucle de ordenes
mysql_free_result($tabla2); // libera los registros de la tabla
?>
Mi problema es que en la linea que toma las variables (de javascript) del array msg[] toma muy bien el valor $vartxt y lo asigna a las variables de javascript msg[0] etc, pero en el contenedor, es decir del otro lado del simbolo igual no me arroja el resultado.
No se que estoy haciendo mal, si me pueden ayudar se los agraqdeceré
Atentamente
Jorge