그누보드 [G5] select 를 편리하게 함수 option_selected 활용
페이지 정보
본문
select 를 편리하게 이용하도록 도와주는 함수 option_selected 활용하기
그누보드5 / lib / common.lib.php
function option_selected($value, $selected, $text='')
{
if (!$text) $text = $value;
if ($value == $selected)
return "<option value=\"{$value}\" selected=\"selected\">{$text}</option>\n";
else
return "<option value=\"{$value}\">{$text}</option>\n";
}
[ 적용예 ]
<select name="qa_use_editor" id="qa_use_editor">
<?php echo option_selected(0, $qaconfig['qa_use_editor'], '사용안함'); ?>
<?php echo option_selected(1, $qaconfig['qa_use_editor'], '사용함'); ?>
</select>
[ 응용예 ]
그누보드5 / extended / user.config.php 에 아래와 같이 내용 추가
<?php
$g5['phone_1'] = array('02'=>'02', '031'=>'031', '032'=>'032', '033'=>'033', '041'=>'041', '042'=>'042', '043'=>'043', '044'=>'044', '051'=>'051', '052'=>'052', '053'=>'053', '054'=>'054', '055'=>'055', '061'=>'061', '062'=>'062', '063'=>'063', '064'=>'064', '070'=>'070', '0505'=>'0505', '0502'=>'0502');
$g5['phone_2'] = array('010'=>'010', '011'=>'011', '016'=>'016', '017'=>'017', '018'=>'018', '019'=>'019', '070'=>'070');
$g5['phone_3'] = array('02'=>'02', '031'=>'031', '032'=>'032', '033'=>'033', '041'=>'041', '042'=>'042', '043'=>'043', '044'=>'044', '051'=>'051', '052'=>'052', '053'=>'053', '054'=>'054', '055'=>'055', '061'=>'061', '062'=>'062', '063'=>'063', '064'=>'064', '010'=>'010', '011'=>'011', '016'=>'016', '017'=>'017', '018'=>'018', '019'=>'019', '070'=>'070', '0505'=>'0505', '0502'=>'0502');
?>
불러올 페이지에 아래와 같이 추가
<select name="spon_hp_1">
<?php
foreach ($g5['phone_2'] as $key => $val) {
echo option_selected($val);
}
?>
</select>
그누보드5 / lib / common.lib.php
function option_selected($value, $selected, $text='')
{
if (!$text) $text = $value;
if ($value == $selected)
return "<option value=\"{$value}\" selected=\"selected\">{$text}</option>\n";
else
return "<option value=\"{$value}\">{$text}</option>\n";
}
[ 적용예 ]
<select name="qa_use_editor" id="qa_use_editor">
<?php echo option_selected(0, $qaconfig['qa_use_editor'], '사용안함'); ?>
<?php echo option_selected(1, $qaconfig['qa_use_editor'], '사용함'); ?>
</select>
[ 응용예 ]
그누보드5 / extended / user.config.php 에 아래와 같이 내용 추가
<?php
$g5['phone_1'] = array('02'=>'02', '031'=>'031', '032'=>'032', '033'=>'033', '041'=>'041', '042'=>'042', '043'=>'043', '044'=>'044', '051'=>'051', '052'=>'052', '053'=>'053', '054'=>'054', '055'=>'055', '061'=>'061', '062'=>'062', '063'=>'063', '064'=>'064', '070'=>'070', '0505'=>'0505', '0502'=>'0502');
$g5['phone_2'] = array('010'=>'010', '011'=>'011', '016'=>'016', '017'=>'017', '018'=>'018', '019'=>'019', '070'=>'070');
$g5['phone_3'] = array('02'=>'02', '031'=>'031', '032'=>'032', '033'=>'033', '041'=>'041', '042'=>'042', '043'=>'043', '044'=>'044', '051'=>'051', '052'=>'052', '053'=>'053', '054'=>'054', '055'=>'055', '061'=>'061', '062'=>'062', '063'=>'063', '064'=>'064', '010'=>'010', '011'=>'011', '016'=>'016', '017'=>'017', '018'=>'018', '019'=>'019', '070'=>'070', '0505'=>'0505', '0502'=>'0502');
?>
불러올 페이지에 아래와 같이 추가
<select name="spon_hp_1">
<?php
foreach ($g5['phone_2'] as $key => $val) {
echo option_selected($val);
}
?>
</select>
댓글목록
등록된 댓글이 없습니다.