472,347 Members | 2,413 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,347 software developers and data experts.

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 6818
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Brian | last post by:
Hello, I am trying to work out how to have smarty use a string's contents as the display-> template.. ie: $smarty->display($buffer); ...
1
by: Richard | last post by:
I need help. I have a smarty based program that I am modifying. I have a smarty template file that consists of smarty and HTML. I need to...
0
by: Matt | last post by:
geez, i've done this a million times, you'd think i could get it right. uploading to production server for a new site, and part of the head.inc...
3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on...
5
by: webguynow | last post by:
I like Smarty but I may have to design something similar myself, bc I'm having trouble getting it installed on my Shared WebHost. There are good...
0
by: ev45ive | last post by:
Hi! I have smth. like this: file.php: <?php SmartyValidate::connect($smarty); //SmartyValidate::register_form('register');
38
by: joeschnell | last post by:
First week of the current trimester and we've taken a huge leap from writing little code snippets of loops and switches to writing an entire program,...
1
by: sksksk | last post by:
I want to achieve the following process in the smarty for $item one i should be able to get the value using loop.index, but without any luck. ...
0
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.