473,385 Members | 1,256 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 6937
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); obviously $buffer isn't a filename, but a smarty template...
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 integrate some PHP database calls into it. My problem...
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 that starts everything up looks like this: echo...
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 tables. The tables are referenced by linked...
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 my hard drive and link to them rather than the...
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 examples out there. One on CodeWalkers...
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, and expecting it to work! I, nor anyone else in...
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. any help is appreciated. <?php for ($i = 1; $i...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.