html_options関数

この関数は、どの要素が選択されるかを指定できます。値と出力属性を指定するか、オプションの置換を指定する必要があります。

If 指定された要素value は配列であり、OPTGROUP 処理として使用され、再帰をサポートします。すべての出力は XHTML と互換性があります。

オプションの属性名が指定されている場合、オプション リストは次の場所に配置されます。 <選択 name="groupname"></select> タグの配置。指定しない場合は、オプションのリストのみが生成されます。

上の表に記載されていないその他のパラメータは、 <select> ; 「名前/属性」のペアとしてタグ内に表示されます。オプションの属性名が指定されていない場合 これらのパラメータは無視されます。

eg1:

test.php:

require( 'Smarty.class.php');
$smarty = 新しい Smarty;
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
$smarty- >assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
Johnson','Carlie Brown'));
$smarty->assign('customer_id', 1001 );
$smarty->display('test.html');

test.html:

<名前を選択=customer_id>
{html_options 値=$cust_ids selected=$customer_id 出力=$cust_names}
</select>




例 2:

test.php:
require('Smarty.class.php');
$smarty = 新しい Smarty;
$smarty->assign(' cust_options', array(
1001 => 'ジョー・シュモー',
1002 => 'ジャック・スミス',
1003 => 'ジェーン・ジョンソン',
1004 => 'チャーリーBrown'));
$smarty->assign('customer_id', 1001);
$smarty->display('test.html');

テスト。 html:
<select name=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"> ;ジャック スミス</option>
<option value="1002">ジェーン ジョンソン</option>
<option value="1003">チャーリー ブラウン</option>
< /select>

微信图片_20180313114508.png#

学び続ける
||
<?php echo "html_options函数";
私たちについて 免責事項 Sitemap
PHP中国語ウェブサイト:福祉オンライン PHP トレーニング,PHP 学習者の迅速な成長を支援します!