Web page hosting and cheap domain registration register services
 

Sponsers:

 

 

 

Smarty Manual
PrevChapter 8. Custom FunctionsNext

html_radios

Attribute NameTypeRequiredDefaultDescription
namestringNoradioname of radio list
valuesarrayYes, unless using options attributen/aan array of values for radio buttons
outputarrayYes, unless using options attributen/aan array of output for radio buttons
selectedstringNoemptythe selected radio element
optionsassociative arrayYes, unless using values and outputn/aan associative array of values and output
separatorstringNoemptystring of text to separate each radio item

html_radios is a custom function that creates html radio button group with provided data. It takes care of which item is selected by default as well. Required attributes are values and output, unless you use options instead. All output is XHTML compatible.

All parameters that are not in the list above are printed as name/value-pairs inside each of the created <input>-tags.

Example 8-9. html_radios

index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');


index.tpl:

{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="<br />"}


index.php:

require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_radios', array(
			1000 => 'Joe Schmoe',
			1001 => 'Jack Smith',
			1002 => 'Jane Johnson',
			1003 => 'Charlie Brown'));
$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');


index.tpl:

{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}


OUTPUT: (both examples)

<input type="radio" name="id" value="1000">Joe Schmoe<br />
<input type="radio" name="id" value="1001" checked="checked">Jack Smith<br />
<input type="radio" name="id" value="1002">Jane Johnson<br />
<input type="radio" name="id" value="1003">Charlie Brown<br />

PrevHomeNext
html_optionsUphtml_select_date
 

 

 

 

Domain registration by Acive-Domain.com | Register domain name & domain registration  

Disclaimers: This document is provided as free service for the benefits of Active-Venture.com's web hosting customers only.

 
Quotes: To take the difficulties, setback and sorrows of life as a challenge which to overcome makes us stronger rather than unjust punishment which should not happen to us requires faith and courage.