콤보박스 출력용 함수

· 19년 전 · 2530
<?
자주사용하는 콤보박스의 기능중 달력을 년,월,일을 많이 쓰는데 다소 무식해(!)보이지만
코딩을 대폭 줄여주는 콤보박스 함수

//콤보 박스를 생성한다. Y-년, M-월, D-일
function getCboCalender($verYear, $verMonth, $verDay, $selYear="", $selMonth="", $selDay="", $mtype="D", $is_print="1", $class=''){
$msg = "";

//if($selYear == "") $selYear = date('Y');
//if($selMonth == "") $selMonth = date('n');
//if($selDay == "") $selDay = date('j');

if($class!='') $class = 'class='.$class;

if($mtype == "Y" || $mtype == "M" || $mtype == "D"){
$msg = '<select name="'.$verYear.'" '.$class.'>';
$msg .= '<option value="">====</option>';
for($i=1997; $i<=2007; $i++){
if($i == $selYear)
$msg .= '<option value="'.$i.'" selected>'.$i.'</option>';
else
$msg .= '<option value="'.$i.'">'.$i.'</option>';
}
$msg .= "</select>년   ";
}

if($mtype == "M" || $mtype == "D"){
$msg .= '<select name="'.$verMonth.'" '.$class.'>';
$msg .= '<option value="">==</option>';
for($i=1; $i<=12; $i++){
if($i == $selMonth)
$msg .= '<option value="'.$i.'" selected>'.$i.'</option>';
else
$msg .= '<option value="'.$i.'">'.$i.'</option>';
}
$msg .= "</select>월   ";
}

if($mtype == "D"){
$msg .= '<select name="'.$verDay.'" '.$class.'>';
$msg .= '<option value="">==</option>';
for($i=1; $i<=31; $i++){
if($i == $selDay)
$msg .= '<option value="'.$i.'" selected>'.$i.'</option>';
else
$msg .= '<option value="'.$i.'">'.$i.'</option>';
}
$msg .= "</select>일   ";
}

if($is_print)
echo $msg;
else
return $msg;
}

사용법은

'syear','smonth','sday'는 select박스의 변수명이 되고

$syear, $smonth, $sday는 입력값이 됩니다.

echo getCboCalender('syear', 'smonth', 'sday', $syear, $smonth, $sday);

특히 달력이나 일정관리에 유용할 것 같네요~~
?><div class='small'>[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]</div>
|
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

+
제목 글쓴이 날짜 조회
19년 전 조회 3,233
19년 전 조회 3,292
19년 전 조회 3,028
19년 전 조회 4,863
19년 전 조회 2,695
19년 전 조회 3,306
19년 전 조회 3,133
19년 전 조회 1,987
19년 전 조회 3,127
19년 전 조회 1,871
19년 전 조회 2,337
19년 전 조회 2,408
19년 전 조회 3,988
19년 전 조회 3,172
19년 전 조회 3,097
19년 전 조회 2,540
19년 전 조회 1,999
19년 전 조회 1,643
19년 전 조회 2,416
19년 전 조회 2,332
19년 전 조회 1,823
19년 전 조회 1,818
19년 전 조회 2,608
19년 전 조회 2,581
19년 전 조회 1,882
19년 전 조회 2,112
19년 전 조회 3,299
19년 전 조회 1,954
19년 전 조회 2,496
19년 전 조회 2,570
19년 전 조회 2,665
19년 전 조회 2,941
19년 전 조회 2,566
19년 전 조회 2,980
19년 전 조회 2,762
19년 전 조회 3,516
19년 전 조회 1,873
19년 전 조회 2,735
19년 전 조회 2,374
19년 전 조회 2,021
19년 전 조회 2,429
19년 전 조회 1,877
19년 전 조회 5,444
19년 전 조회 2,264
19년 전 조회 4,245
19년 전 조회 2,298
19년 전 조회 1,850
19년 전 조회 2,593
19년 전 조회 2,334
19년 전 조회 2,531
19년 전 조회 2,173
19년 전 조회 3,914
19년 전 조회 3,417
19년 전 조회 2,201
19년 전 조회 2,110
19년 전 조회 1,978
19년 전 조회 1,998
19년 전 조회 4,379
19년 전 조회 3,356
19년 전 조회 2,777
19년 전 조회 3,356
19년 전 조회 3,003
19년 전 조회 2,845
19년 전 조회 2,346
19년 전 조회 2,166
19년 전 조회 2,492
19년 전 조회 3,102
19년 전 조회 2,127
19년 전 조회 3,122
19년 전 조회 3,252
19년 전 조회 2,924
19년 전 조회 1,941
19년 전 조회 1,706
19년 전 조회 2,321
19년 전 조회 2,257
19년 전 조회 1,627
19년 전 조회 1,663
19년 전 조회 1,565
19년 전 조회 2,077
19년 전 조회 1,624
19년 전 조회 2,184
19년 전 조회 1,915
19년 전 조회 1,810
19년 전 조회 1,652
19년 전 조회 1,844
19년 전 조회 1,894
19년 전 조회 1,946
19년 전 조회 2,695
19년 전 조회 5,321
19년 전 조회 1,725
19년 전 조회 1,573
19년 전 조회 1,437
19년 전 조회 1,595
19년 전 조회 1,529
19년 전 조회 1,448
19년 전 조회 1,456
19년 전 조회 1,378
19년 전 조회 1,445
19년 전 조회 2,810
19년 전 조회 3,827
🐛 버그신고