rejetto forum

Software => HFS ~ HTTP File Server => HTML & templates => Topic started by: nano28 on May 23, 2012, 10:36:33 PM

Title: Incremental number in template
Post by: nano28 on May 23, 2012, 10:36:33 PM
Hi, I am new in HFS template development.

Can I know whether is it possible to put incremental number automatically?

This is because I want to assign different ID to every filename.

In browser, I hope to get something like this:

<div id="1">Filename 1</div>;
<div id="2">Filename 2</div>;
<div id="3">Filename 3</div>;

... and so on depending on the number of file in the folder.

Thanks.
Title: Re: Incremental number in template
Post by: rejetto on May 24, 2012, 09:19:43 AM
you can do this by using javascript OR by using HFS scripting available in version 2.3
http://www.rejetto.com/wiki/index.php?title=HFS:_Template_macros

{.for|x|1|9|{: <div id="{.^x.}">Filename {.^x.}</div>; :}.}
Title: Re: Incremental number in template
Post by: nano28 on May 24, 2012, 09:26:52 AM
Hi...

Thanks for the reply.

I love to do this using javascript but still don't know how to make it work.

Is it possible to call function from javascript within HTML ID ?

Eg.

//JS code
var num=0;
counter(){
    num++;
    return num;   
}

//HTML body
<div id=counter()>%item-name%</div>
Title: Re: Incremental number in template
Post by: rejetto on May 24, 2012, 09:39:33 AM
it's explained at the link i gave you.

the meaning is: repeat with X from 1 to 9
Title: Re: Incremental number in template
Post by: nano28 on May 26, 2012, 07:18:41 PM
Thanks for the answer.. it works.  :D