[MX]HTML Text Field Extra Space

Hi,

I’m using loadVars to import text from a text file and then put it into a dynamic text field - rendered in HTML. There is an extra space in the first line of text for some reason. I’ve checked the dynamic text field and theres no spaces or returns in it - its empty before putting the text into it.

How can I get rid of that extra line?

:cyclops:

Wanna show us your code?

Also, do you get the extra space if it’s NOT html-ed?

You can trim leading space using either of the following. However, it’s
probably better to not generate the space in the first place, in which case,
we’ll need to see your code.


// removing leading spaces from str...
while (str.charCodeAt(0) == 32)
{
        str = String(str).substr(1);
}

// removing leading whitespace (incl. tabs, returns and so on) from str
while ((var ch = str.charCodeAt(0)) == 32 || ch == 9 || ch == 13 || ch == 10)
{
        str = String(str).substr(1);
}

  • Jim

PS. I really hate the way the “as” tag destroys indenting on one-line IF, WHILE and FOR statements… Ordinaraily I would not use the curly braces, but they’re necessary here to show structure.

If I turn off the ‘Render text as HTML’ option - it doesn’t add this extra line of space.

I’m using split to turn the string into an array - the divider is the number sign #. Heres what the text file variable looks like:

cats=1#2#3&

Theres no space and or breaks in the text field to start with.

:hr: