Write value in layer using eval

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • HareshKarkar
    New Member
    • Aug 2007
    • 1

    Write value in layer using eval

    Hi ,
    I'm calling some Javascript function to write value in the layer. I'm trying to achieve it by using eval() function. Please look at the code below:

    [CODE=javascript]function showMore(tempLa yerNum, tempLayerName) {

    var temp = "step"+tempLaye rNum+"More".toS tring();
    eval(temp).writ e("Hi");

    }
    [/CODE]
    This is very simple code but still not working. Some other place same type of statement is working. Any idea what mistake I'm making here...

    Regards,
    Haresh
    Last edited by gits; Aug 31 '07, 07:45 AM. Reason: added code tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Changed the thread title. Please use a good thread title. Also, don't forget to use code tags when posting code. Thanks!

    Comment

    • gits
      Recognized Expert Moderator Expert
      • May 2007
      • 5388

      #3
      hi ...

      welcome to TSDN ...

      i would never recommend to use eval besides the need to evaluate json-data ... in case you simply want to add text to a html-node use something like the following:

      [CODE=javascript]
      var layer = document.getEle mentById('your_ layer_id');
      var text = 'whatever_text_ may_include_mar kup';

      layer.innerHTML = text;
      [/CODE]

      kind regards

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Originally posted by HareshKarkar
        I'm calling some Javascript function to write value in the layer. I'm trying to achieve it by using eval() function. Please look at the code below:

        [CODE=javascript]function showMore(tempLa yerNum, tempLayerName) {

        var temp = "step"+tempLaye rNum+"More".toS tring();
        eval(temp).writ e("Hi");

        }
        [/CODE]
        Welcome to TSDN!

        You don't need to use eval for this. Show the HTML code for the layer.

        Comment

        Working...