show = 'text' + num
will return a string.. "text1"
Not the value of the variable text1

eval("show = text" + num);
will put the value of text1 intotshow

----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, March 19, 2001 4:21 AM
Subject: [Dynapi-Help] how to make setHtml use variable?


> Can't I use a variable in setHtml()?
> Or - what am I doing wrong?
> The eventlistener returns the number of the headline just fine, but when
trying
> to put the variable in setHtml() to show text1-4 depending on which
headline I
> mouseover, in the textLayer I just see "text1" or "text2" etc, it doesn't
show
> me the contents of the variables.
>
> Thankful for help, here's the code:
>
> <script language="Javascript" src="../src/dynapi.js"></script>
> <script language="Javascript">
> DynAPI.setLibraryPath('../src/lib/')
> DynAPI.include('dynapi.api.*')
> DynAPI.include("dynapi.gui.label.js")
> DynAPI.include("dynapi.gui.list.js")
> </script>
> <script language="Javascript">
> DynAPI.onLoad = function() {
>
> textLayer=new DynLayer(null,290,258,180,185,'#c0c0c0')
>      list = new List()
>      list.moveTo(21,95)
>      list.setWidth(260)
>      list.boldOnSelect(true)
>      list.add("headline 1",1)
>      list.add("headline 2",2)
>      list.add("headline 3",3)
>      list.add("headline 4",4)
>
> var text1 = "some text"
> var text2 = "some new text"
> var text3 = "some other text"
> var text4 = "some old text"
>
>           var myListener = new EventListener()
>           myListener.onmouseover = function(e) {
>                source = e.getSource()
>                source.setBgColor('white')
>                num = source.value
>                         show = 'text' + num
>                         textLayer.setHTML(show)
>           }
>           myListener.onmouseout=function(e) {
>           source=e.getSource()
>           source.setBgColor('silver')
>           }
>           list.items[0].addEventListener(myListener)
>           DynAPI.document.addChild(list)
>           DynAPI.document.addChild(textLayer)
> }
> </script>
>
> /Jesper Bierbum
>
>
>
> _______________________________________________
> Dynapi-Help mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/dynapi-help


_______________________________________________
Dynapi-Help mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/dynapi-help

Reply via email to