468,310 Members | 1,425 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,310 developers. It's quick & easy.

using smarty to generate selection list

Hi there,

does anyone know how to use smarty to generate a selection list without
PHP assigning a array?
eg. a list for selection minutes, but without php to assign a 1~60
array into smarty.

Thanks in advance.

Jul 17 '05 #1
5 6646
also, I want to put in id inside the <select> tag as well.

Jul 17 '05 #2
gl**@tollnz.co.nz wrote:
does anyone know how to use smarty to generate a selection list without
PHP assigning a array?
eg. a list for selection minutes, but without php to assign a 1~60
array into smarty. also, I want to put in id inside the <select> tag as well.


Can't help you with the first question, I think you need to use a PHP
array (but it can be one line, like: $seconds = range(1..60) or
something. Look up the range() function for the exact syntax.

You can put your own attributes in Smarty tags simply like this:

{html_options name="name" options=$options id="id"}

JP

--
Sorry, <de*****@cauce.org> is a spam trap.
Real e-mail address unavailable. 5000+ spams per month.
Jul 17 '05 #3
On 3 Apr 2005 19:36:23 -0700, "gl**@tollnz.co.nz" <gl**@tollnz.co.nz>
wrote:
Hi there,

does anyone know how to use smarty to generate a selection list without
PHP assigning a array?
eg. a list for selection minutes, but without php to assign a 1~60
array into smarty.

Thanks in advance.

<select name="mins" id="mins">
{section name=mins loop=60}
<option value="{$smarty.section.mins.iteration}">
{$smarty.section.mins.iteration}
</option>
{/section}
</select>

HTH =)

Regards,

Ian
--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #4
thanks guys, here is a more challenging question
regarding on Ian's solution,

how do I add 0 infront of the numbers that is less than 10?
so I will have 01, 02, ~ 10

thanks in advance

Jul 17 '05 #5
On 5 Apr 2005 19:47:04 -0700, "gl**@tollnz.co.nz" <gl**@tollnz.co.nz>
wrote:
thanks guys, here is a more challenging question
regarding on Ian's solution,

how do I add 0 infront of the numbers that is less than 10?
so I will have 01, 02, ~ 10

thanks in advance

Use the string_format modifier:
<http://smarty.php.net/manual/en/language.modifier.string.format.php>
{section name=foo loop=10}
<option name="{$smarty.section.foo.iteration}">
{$smarty.section.foo.iteration|string_format:"%02d "}
</option>
{/section}

Regards,

Ian
--
Ian.H
digiServ Network
London, UK
http://digiserv.net/
Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Brian | last post: by
1 post views Thread by Richard | last post: by
reply views Thread by Matt | last post: by
3 posts views Thread by Random Person | last post: by
1 post views Thread by Daveyk0 | last post: by
5 posts views Thread by webguynow | last post: by
reply views Thread by ev45ive | last post: by
1 post views Thread by sksksk | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.