콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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>년&nbsp;&nbsp;&nbsp;";
}

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>월&nbsp;&nbsp;&nbsp;";
}

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>일&nbsp;&nbsp;&nbsp;";
}

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,686
19년 전 조회 3,300
19년 전 조회 3,131
19년 전 조회 1,980
19년 전 조회 3,121
19년 전 조회 1,863
19년 전 조회 2,331
19년 전 조회 2,402
19년 전 조회 3,981
19년 전 조회 3,166
19년 전 조회 3,092
19년 전 조회 2,536
19년 전 조회 1,995
19년 전 조회 1,637
19년 전 조회 2,407
19년 전 조회 2,327
19년 전 조회 1,816
19년 전 조회 1,812
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,657
19년 전 조회 2,934
19년 전 조회 2,560
19년 전 조회 2,974
19년 전 조회 2,758
19년 전 조회 3,511
19년 전 조회 1,867
19년 전 조회 2,730
19년 전 조회 2,368
19년 전 조회 2,018
19년 전 조회 2,425
19년 전 조회 1,869
19년 전 조회 5,437
19년 전 조회 2,254
19년 전 조회 4,240
19년 전 조회 2,296
19년 전 조회 1,845
19년 전 조회 2,587
19년 전 조회 2,328
19년 전 조회 2,526
19년 전 조회 2,163
19년 전 조회 3,910
19년 전 조회 3,415
19년 전 조회 2,198
19년 전 조회 2,104
19년 전 조회 1,971
19년 전 조회 1,989
19년 전 조회 4,369
19년 전 조회 3,348
19년 전 조회 2,773
19년 전 조회 3,346
19년 전 조회 2,998
19년 전 조회 2,837
19년 전 조회 2,339
19년 전 조회 2,159
19년 전 조회 2,484
19년 전 조회 3,093
19년 전 조회 2,119
19년 전 조회 3,114
19년 전 조회 3,246
19년 전 조회 2,916
19년 전 조회 1,937
19년 전 조회 1,699
19년 전 조회 2,316
19년 전 조회 2,251
19년 전 조회 1,623
19년 전 조회 1,656
19년 전 조회 1,560
19년 전 조회 2,068
19년 전 조회 1,613
19년 전 조회 2,178
19년 전 조회 1,910
19년 전 조회 1,801
19년 전 조회 1,645
19년 전 조회 1,838
19년 전 조회 1,885
19년 전 조회 1,942
19년 전 조회 2,687
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,822
🐛 버그신고