콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,026
19년 전 조회 4,861
19년 전 조회 2,691
19년 전 조회 3,303
19년 전 조회 3,132
19년 전 조회 1,982
19년 전 조회 3,123
19년 전 조회 1,869
19년 전 조회 2,333
19년 전 조회 2,404
19년 전 조회 3,984
19년 전 조회 3,172
19년 전 조회 3,096
19년 전 조회 2,539
19년 전 조회 1,999
19년 전 조회 1,641
19년 전 조회 2,412
19년 전 조회 2,330
19년 전 조회 1,820
19년 전 조회 1,816
19년 전 조회 2,603
19년 전 조회 2,579
19년 전 조회 1,877
19년 전 조회 2,110
19년 전 조회 3,295
19년 전 조회 1,950
19년 전 조회 2,495
19년 전 조회 2,568
19년 전 조회 2,660
19년 전 조회 2,937
19년 전 조회 2,563
19년 전 조회 2,978
19년 전 조회 2,760
19년 전 조회 3,512
19년 전 조회 1,871
19년 전 조회 2,732
19년 전 조회 2,371
19년 전 조회 2,020
19년 전 조회 2,428
19년 전 조회 1,874
19년 전 조회 5,440
19년 전 조회 2,260
19년 전 조회 4,244
19년 전 조회 2,297
19년 전 조회 1,848
19년 전 조회 2,590
19년 전 조회 2,333
19년 전 조회 2,528
19년 전 조회 2,170
19년 전 조회 3,911
19년 전 조회 3,415
19년 전 조회 2,199
19년 전 조회 2,107
19년 전 조회 1,975
19년 전 조회 1,993
19년 전 조회 4,373
19년 전 조회 3,352
19년 전 조회 2,775
19년 전 조회 3,352
19년 전 조회 3,002
19년 전 조회 2,841
19년 전 조회 2,343
19년 전 조회 2,163
19년 전 조회 2,487
19년 전 조회 3,099
19년 전 조회 2,125
19년 전 조회 3,116
19년 전 조회 3,250
19년 전 조회 2,921
19년 전 조회 1,940
19년 전 조회 1,702
19년 전 조회 2,318
19년 전 조회 2,255
19년 전 조회 1,626
19년 전 조회 1,660
19년 전 조회 1,562
19년 전 조회 2,073
19년 전 조회 1,620
19년 전 조회 2,181
19년 전 조회 1,913
19년 전 조회 1,806
19년 전 조회 1,650
19년 전 조회 1,843
19년 전 조회 1,887
19년 전 조회 1,945
19년 전 조회 2,693
19년 전 조회 5,319
19년 전 조회 1,722
19년 전 조회 1,569
19년 전 조회 1,435
19년 전 조회 1,592
19년 전 조회 1,527
19년 전 조회 1,447
19년 전 조회 1,452
19년 전 조회 1,374
19년 전 조회 1,443
19년 전 조회 2,806
19년 전 조회 3,825
🐛 버그신고