For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > January 2005 > Re: [SMARTY] Is possible to create this html source with Smarty









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] Is possible to create this html source with Smarty
Bertrand Zuchuat

2005-01-12, 8:58 am


Le 12 janv. 05, =E0 10:52, Dasa a =E9crit :

> <select name=3D"blah">
> <optgroup label=3D"Options 1"></optgroup>
> <option value=3D"11">Options 11</option>
> <option value=3D"12">Options 12</option>
> <optgroup label=3D"Options 2"></optgroup>
> <option value=3D"21">Options 11</option>
> <option value=3D"22">Options 22</option>
> </select>


Hello,

<select name=3D"blah">
{foreach key=3Dkey item=3Dvalues from=3Dblah}
<optgroup label=3D"">{$key}</optgroup>
{foreach key=3Dlkey item=3Ditem from=3Dvalues}
<option value=3D"{$lkey}">{$item}</option>
{/foreach}
{/foreach}


with this array

$values =3D array(
'option 1' =3D> array('11' =3D> 'Options 11', '12' =3D> 'Options 12'),
'option 2' =3D> array('21' =3D> 'Options 21', '22' =3D> 'Options 22'),
....
);

$tpl->assign($blah, $values);

Bye

Bertrand=
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com