Ver Mensaje Individual
  #8 (permalink)  
Antiguo 28/04/2004, 09:00
aeb_asturias
 
Fecha de Ingreso: marzo-2004
Mensajes: 550
Antigüedad: 20 años, 1 mes
Puntos: 7
Un ejemplo con datos fijos donde si funciona es:

..........
.........
<script type="text/javascript">
<!--
d = new dTree('d');

d.add(0,-1,'My example tree');
d.add(1,0,'Node 1','example01.html');
d.add(2,0,'Node 2','example01.html');
d.add(3,1,'Node 1.1','example01.html');
..........................................
..........................................

A la funcion add() ademas de los tres parametros comentados yo anteriormente se le pueden pasar mas pero bueno ahi no esta el problema porque tambien se le pueden pasar solo los tres primeros.

El problema esta en el tercer parametro que es un string y yo le paso una variable php. Me falla poniendo:

d.add(<?echo $num;?>,0,<? echo $dominio;?>) o
d.add(<?echo $num;?>,0,'<? echo $dominio;?>')

Un trozo del codigo javascript que contiene la funcion add es:


function Node(id, pid, name, url, title, target, icon, iconOpen, open) {

this.id = id;

this.pid = pid;

this.name = name;

this.url = url;

this.title = title;

this.target = target;

this.icon = icon;

this.iconOpen = iconOpen;

this._io = open || false;

this._is = false;

this._ls = false;

this._hc = false;

this._ai = 0;

this._p;

};



// Tree object

function dTree(objName) {

this.config = {

target : null,

folderLinks : true,

useSelection : true,

useCookies : true,

useLines : true,

useIcons : true,

useStatusText : false,

closeSameLevel : false,

inOrder : false

}

this.icon = {

root : 'img/base.gif',

folder : 'img/folder.gif',

folderOpen : 'img/folderopen.gif',

node : 'img/page.gif',

empty : 'img/empty.gif',

line : 'img/line.gif',

join : 'img/join.gif',

joinBottom : 'img/joinbottom.gif',

plus : 'img/plus.gif',

plusBottom : 'img/plusbottom.gif',

minus : 'img/minus.gif',

minusBottom : 'img/minusbottom.gif',

nlPlus : 'img/nolines_plus.gif',

nlMinus : 'img/nolines_minus.gif'

};

this.obj = objName;

this.aNodes = [];

this.aIndent = [];

this.root = new Node(-1);

this.selectedNode = null;

this.selectedFound = false;

this.completed = false;

};



// Adds a new node to the node array

dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {

this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);

};

Un saludo y espero que alguien sepa porque esa variable php no es entendida por javascript como un string.