콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,230
19년 전 조회 3,290
19년 전 조회 3,027
19년 전 조회 4,862
19년 전 조회 2,694
19년 전 조회 3,305
19년 전 조회 3,133
19년 전 조회 1,984
19년 전 조회 3,124
19년 전 조회 1,870
19년 전 조회 2,335
19년 전 조회 2,405
19년 전 조회 3,987
19년 전 조회 3,172
19년 전 조회 3,096
19년 전 조회 2,539
19년 전 조회 1,999
19년 전 조회 1,642
19년 전 조회 2,413
19년 전 조회 2,332
19년 전 조회 1,822
19년 전 조회 1,818
19년 전 조회 2,605
19년 전 조회 2,580
19년 전 조회 1,880
19년 전 조회 2,111
19년 전 조회 3,296
19년 전 조회 1,952
19년 전 조회 2,495
19년 전 조회 2,569
19년 전 조회 2,664
19년 전 조회 2,939
19년 전 조회 2,564
19년 전 조회 2,978
19년 전 조회 2,760
19년 전 조회 3,516
19년 전 조회 1,872
19년 전 조회 2,734
19년 전 조회 2,372
19년 전 조회 2,020
19년 전 조회 2,428
19년 전 조회 1,875
19년 전 조회 5,441
19년 전 조회 2,261
19년 전 조회 4,244
19년 전 조회 2,298
19년 전 조회 1,849
19년 전 조회 2,591
19년 전 조회 2,334
19년 전 조회 2,529
19년 전 조회 2,171
19년 전 조회 3,912
19년 전 조회 3,416
19년 전 조회 2,201
19년 전 조회 2,107
19년 전 조회 1,975
19년 전 조회 1,995
19년 전 조회 4,375
19년 전 조회 3,353
19년 전 조회 2,775
19년 전 조회 3,354
19년 전 조회 3,003
19년 전 조회 2,843
19년 전 조회 2,344
19년 전 조회 2,165
19년 전 조회 2,489
19년 전 조회 3,101
19년 전 조회 2,126
19년 전 조회 3,118
19년 전 조회 3,251
19년 전 조회 2,923
19년 전 조회 1,941
19년 전 조회 1,703
19년 전 조회 2,319
19년 전 조회 2,256
19년 전 조회 1,627
19년 전 조회 1,662
19년 전 조회 1,564
19년 전 조회 2,076
19년 전 조회 1,621
19년 전 조회 2,182
19년 전 조회 1,913
19년 전 조회 1,807
19년 전 조회 1,651
19년 전 조회 1,843
19년 전 조회 1,889
19년 전 조회 1,946
19년 전 조회 2,693
19년 전 조회 5,320
19년 전 조회 1,724
19년 전 조회 1,569
19년 전 조회 1,436
19년 전 조회 1,594
19년 전 조회 1,527
19년 전 조회 1,448
19년 전 조회 1,453
19년 전 조회 1,377
19년 전 조회 1,445
19년 전 조회 2,807
19년 전 조회 3,827
🐛 버그신고