[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [ic] Loop with embedded Perl


Quoting Jeff Boes (suppressed):
> I'm stuck on this:
> 
>         <select name="year">
>         <option value="">Select one</option>
>         [loop list=`1981..1900+(localtime())[5]`
>          ] <option value="[loop-code]">[loop-code]</option>
>         [/loop]
>         <option value="prior 1981">1980 or older</option>
>         </select>
> 
> What I'm attempting to generate is a drop-down list with a series of
> year values, 1981 to the current year.
> 
> If I can get this working, what I'd really like is ..
> 
> list=`reverse 1981..1900+(localtime())[5]`
> 
> but at present neither of these works; I get an empty list and only the
> last option.

You might want to join it with something. [loop ...] is ITL, not
Perl, and it doesn't accept Perl array values directly...

         [loop list=`
			my $year = 1900 + (localtime())[5];
			return join(" ", 1981 .. $year);
		`
          ] <option value="[loop-code]">[loop-code]</option>
         [/loop]

Sometimes trying to be too terse causes problems. I suggest that
when you have trouble you just write a function and skip the
mimimalist one-liner approach. And not using whitespace makes
code much harder to read.

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.765.647.1295  tollfree 800-949-1889 <suppressed>

People who want to share their religious views with you
almost never want you to share yours with them. -- Dave Barry
_______________________________________________
interchange-users mailing list
suppressed
http://www.icdevgroup.org/mailman/listinfo/interchange-users


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.