Javascript funtion in ListRecord

Javascript funtion in ListRecord

Hi, i am trying to add spaces depending on the level.
heres the code i have:

to create the spaces in javsacript

function displaySpaces(spaces)
    var i=0;
    for (i=0;i<=spaces;i++)
        document.getElementById("divSpaces").innerHTML = "XXXX";
    document.title="os espaco sao : " + spaces;

and in the listrecords i have a expresion with this:
 "<div id='teste' onload='displaySpaces(" + TestListRecord.List.Current.Test.Level + ")'></div> <div id='divSpaces'></div>"

But isn't working, what am i doing wrong?
Hi Luís,

I'm not really sure what you are trying to do, but bear in mind that two white spaces in HTML will render as a single one. If you need to create several spaces you need to use the &nbsp; (non-breaking space html char). Also the onload event can not be fired in DIVs. 

A different approach you can explore is put a style extended property "width:" + (TestListRecord.List.Current.Test.Level * 10) + "px;"

Tiago Simões

EDIT: of course Hermínio is right, what I was thinking was "margin-left" or "padding-left" instead of width
Hi, what i want is something like this
if i have leve = 2, creates 2 spaces, level=3 create 3 spaces, that XXXX was for a example, and i forget to change.

The style property is a good ideia, i will try it, if it works then i say something.

Hi Luis,

I would just like to add to Tiago's reply that you might consider using the "padding-left" property instead of the "width" if you're using a ListRecords/TableRecords.

never remembered those options. It worked