rejetto forum

Incremental number in template

nano28 · 5 · 4498

0 Members and 1 Guest are viewing this topic.

Offline nano28

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
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.


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
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>; :}.}


Offline nano28

  • Occasional poster
  • *
    • Posts: 3
    • View Profile
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>
« Last Edit: May 24, 2012, 11:35:43 AM by nano28 »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13523
    • View Profile
it's explained at the link i gave you.

the meaning is: repeat with X from 1 to 9


Offline nano28

  • Occasional poster
  • *
    • Posts: 3
    • View Profile