콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,228
19년 전 조회 3,287
19년 전 조회 3,024
19년 전 조회 4,858
19년 전 조회 2,687
19년 전 조회 3,301
19년 전 조회 3,132
19년 전 조회 1,981
19년 전 조회 3,122
19년 전 조회 1,863
19년 전 조회 2,331
19년 전 조회 2,402
19년 전 조회 3,982
19년 전 조회 3,167
19년 전 조회 3,093
19년 전 조회 2,536
19년 전 조회 1,996
19년 전 조회 1,639
19년 전 조회 2,408
19년 전 조회 2,327
19년 전 조회 1,816
19년 전 조회 1,813
19년 전 조회 2,602
19년 전 조회 2,577
19년 전 조회 1,875
19년 전 조회 2,107
19년 전 조회 3,293
19년 전 조회 1,947
19년 전 조회 2,491
19년 전 조회 2,566
19년 전 조회 2,659
19년 전 조회 2,934
19년 전 조회 2,560
19년 전 조회 2,974
19년 전 조회 2,758
19년 전 조회 3,511
19년 전 조회 1,868
19년 전 조회 2,730
19년 전 조회 2,368
19년 전 조회 2,018
19년 전 조회 2,425
19년 전 조회 1,870
19년 전 조회 5,438
19년 전 조회 2,257
19년 전 조회 4,240
19년 전 조회 2,296
19년 전 조회 1,845
19년 전 조회 2,587
19년 전 조회 2,330
19년 전 조회 2,527
19년 전 조회 2,164
19년 전 조회 3,910
19년 전 조회 3,415
19년 전 조회 2,198
19년 전 조회 2,104
19년 전 조회 1,972
19년 전 조회 1,990
19년 전 조회 4,369
19년 전 조회 3,348
19년 전 조회 2,773
19년 전 조회 3,347
19년 전 조회 2,999
19년 전 조회 2,838
19년 전 조회 2,340
19년 전 조회 2,159
19년 전 조회 2,484
19년 전 조회 3,094
19년 전 조회 2,119
19년 전 조회 3,114
19년 전 조회 3,247
19년 전 조회 2,916
19년 전 조회 1,937
19년 전 조회 1,700
19년 전 조회 2,316
19년 전 조회 2,252
19년 전 조회 1,623
19년 전 조회 1,658
19년 전 조회 1,560
19년 전 조회 2,068
19년 전 조회 1,614
19년 전 조회 2,178
19년 전 조회 1,910
19년 전 조회 1,801
19년 전 조회 1,645
19년 전 조회 1,839
19년 전 조회 1,885
19년 전 조회 1,942
19년 전 조회 2,688
19년 전 조회 5,315
19년 전 조회 1,719
19년 전 조회 1,566
19년 전 조회 1,432
19년 전 조회 1,589
19년 전 조회 1,523
19년 전 조회 1,443
19년 전 조회 1,450
19년 전 조회 1,372
19년 전 조회 1,440
19년 전 조회 2,803
19년 전 조회 3,823
🐛 버그신고