Announcement

Collapse
No announcement yet.

[SOLVED] SC Blank App Altering Code in <script> tags

Collapse
This topic is closed.
X
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [SOLVED] SC Blank App Altering Code in <script> tags

    I'm echoing some HTML and JS to the browser in a blank app. Excerpts of the code is as follows:

    $dump = " <script>
    ...
    for (var i = 0; i < rows.length; i++){

    // please note that rows has been properly initialized with an array of objects prior

    var cells = rows[i].split('\t');
    ...
    </script>";

    echo $dump;

    When this is run, I keep getting a console log error such as "unable to call member of undefined" and the source shows this

    var cells = rows.split('\t');

    i.e. it drops the index variable i and of course rows is not the object so the split function cannot be called.

    I also notice when I run the blank app, it seems to think i is an SC variable and prompts for the value (i.e it also places "i" in the Global Variables section of the development area).

    I have tried using other variable names and also using multi line echo <<< but I get same results.

    Has anyone encountered and fixed something like this?

  • #2
    Hi...
    Try This
    $dump = " <script>
    ...
    for (var i = 0; i < rows.length; i++){

    // please note that rows has been properly initialized with an array of objects prior

    var cells = rows\[i\].split('\t');
    ...
    </script>";

    Comment


    • #3
      Thank you, works.

      Comment


      • #4
        Change Title to [SOLVED]

        Comment

        Working...
        X