html_options ??
? ??? ?? ??? ????? ??? ? ????. ?? ?? ??? ????? ?? ??? ???? ???.
??? ?? ??? ?? OPTGROUP?? ?????. ??? ?????. ?? ??? XHTML ??? ?????.
??? ?? ??? ???? ?? ??? <select? ?????. name = "groupname" > "? ??? ???? ?????. ??? ?? ??? ???? ?? ?? ??? ????? ?????.
test.php:
require('Smarty.class.php');$smarty = new Smarty;
$smarty->ass( 'cust_ids', array(1000,1001,1002,1003));$smarty->??('cust_names', array('Joe Schmoe','Jack Smith','JaneJohnson','Carlie Brown' ));$smarty->??('customer_id', 1001);
$smarty->display('test.html');
test.html:
<?? ??= customer_id>
{html_options ?=$cust_ids ???=$customer_id ??=$cust_names}
</select>
eg2:
test.php:
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->ass('cust_options', array(
1001 => 'Joe Schmoe' ,
1002 => '? ???',
1003 => '?? ??',
1004 => '?? ???'));
$smarty->sign('customer_id', 1001);
$ smarty->display('test.html');
test.html:
<?? ??=customer_id>
{html_options options=$cust_options selected=$customer_id}
</select>
輸?:?
<select name=customer_id>
<option value="1000">Joe Schmoe</option>
<option value="1001" selected="selected">Jack Smith</option> ;
<option value="1002">?? ??</option>
<option value="1003">?? ???</option>
</select>