Transfer variable to JavaScript expression

Transfer variable to JavaScript expression

  
im currently trying to implement the following:
"<SCRIPT type=""text/javascript"">

var String = """ + LocalString + """;
var Levels = String.split("";"");

for(i=0; i < Levels.length; i++){
    
    If(Levels[i] == 0)
    {
        document.write('...
    } else {
        document.write('...
    }
    
}

</SCRIPT>"
but it seems as if i cant assign the local string to the js string.
since no iterations are performed.

what am i doing wrong? is there another way to get a local value into the js expression?

thank you very much!

Hi Enigma,

Which place are you trying to use that code?

Best Regards,
Diogo Miguel
hi miguel, within a screen expression in a record list (escape content set to no)
"<script type=text/javascript>

var String = '" + LocalString + "';
var Levels = String.split(';');

for(i=0; i < Levels.length; i++){
    
    if(Levels[i] == 0)
    {
        document.write('...');
    }
    else
    {
        document.write('...');
    }   
}
</script>"

Be carefull beacuse javascript is case sensitive.
The problem isn't in the variable, is in the javascript code. Ex: If -> if

Best Regards,
Diogo Miguel
Hi,

Also it is a very bad practice to use document write instructions.
In the case of a ajax refreshing that expression you will end up with a white page.

By the way, what are you trying to implement?
Maybe we can give some sugestions on how to do it.

Regards,
João Rosado
basically i want to create an indent in a list, by printing one of two images a certain amount of times (according to the level of the record)
solved it with a web block, that outputs a record list horizontally, which is obtained by splitting the string