콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,576
19년 전 조회 3,638
19년 전 조회 3,389
19년 전 조회 5,198
19년 전 조회 3,028
19년 전 조회 3,639
19년 전 조회 3,473
19년 전 조회 2,330
19년 전 조회 3,445
19년 전 조회 2,195
19년 전 조회 2,649
19년 전 조회 2,748
19년 전 조회 4,318
19년 전 조회 3,509
19년 전 조회 3,398
19년 전 조회 2,854
19년 전 조회 2,308
19년 전 조회 1,946
19년 전 조회 2,728
19년 전 조회 2,640
19년 전 조회 2,118
19년 전 조회 2,123
19년 전 조회 2,929
19년 전 조회 2,874
19년 전 조회 2,184
19년 전 조회 2,425
19년 전 조회 3,616
19년 전 조회 2,269
19년 전 조회 2,793
19년 전 조회 2,870
19년 전 조회 2,991
19년 전 조회 3,248
19년 전 조회 2,883
19년 전 조회 3,316
19년 전 조회 3,071
19년 전 조회 3,816
19년 전 조회 2,192
19년 전 조회 3,042
19년 전 조회 2,683
19년 전 조회 2,325
19년 전 조회 2,734
19년 전 조회 2,198
19년 전 조회 5,754
19년 전 조회 2,577
19년 전 조회 4,551
19년 전 조회 2,644
19년 전 조회 2,179
19년 전 조회 2,902
19년 전 조회 2,658
19년 전 조회 2,838
19년 전 조회 2,481
19년 전 조회 4,230
19년 전 조회 3,708
19년 전 조회 2,510
19년 전 조회 2,436
19년 전 조회 2,287
19년 전 조회 2,306
19년 전 조회 4,679
19년 전 조회 3,652
19년 전 조회 3,079
19년 전 조회 3,661
19년 전 조회 3,284
19년 전 조회 3,148
19년 전 조회 2,646
19년 전 조회 2,465
19년 전 조회 2,792
19년 전 조회 3,382
19년 전 조회 2,405
19년 전 조회 3,432
19년 전 조회 3,539
19년 전 조회 3,215
19년 전 조회 2,227
19년 전 조회 1,998
19년 전 조회 2,625
19년 전 조회 2,561
19년 전 조회 1,912
19년 전 조회 1,954
19년 전 조회 1,847
19년 전 조회 2,353
19년 전 조회 1,911
19년 전 조회 2,474
19년 전 조회 2,219
19년 전 조회 2,105
19년 전 조회 1,949
19년 전 조회 2,125
19년 전 조회 2,169
19년 전 조회 2,228
19년 전 조회 2,958
19년 전 조회 5,600
19년 전 조회 2,022
19년 전 조회 1,858
19년 전 조회 1,718
19년 전 조회 1,892
19년 전 조회 1,807
19년 전 조회 1,732
19년 전 조회 1,767
19년 전 조회 1,667
19년 전 조회 1,719
19년 전 조회 3,087
19년 전 조회 4,121