콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,365
19년 전 조회 3,445
19년 전 조회 3,161
19년 전 조회 4,998
19년 전 조회 2,836
19년 전 조회 3,453
19년 전 조회 3,279
19년 전 조회 2,148
19년 전 조회 3,274
19년 전 조회 2,008
19년 전 조회 2,466
19년 전 조회 2,554
19년 전 조회 4,122
19년 전 조회 3,314
19년 전 조회 3,234
19년 전 조회 2,680
19년 전 조회 2,145
19년 전 조회 1,785
19년 전 조회 2,565
19년 전 조회 2,475
19년 전 조회 1,945
19년 전 조회 1,960
19년 전 조회 2,739
19년 전 조회 2,705
19년 전 조회 2,023
19년 전 조회 2,249
19년 전 조회 3,433
19년 전 조회 2,082
19년 전 조회 2,614
19년 전 조회 2,691
19년 전 조회 2,804
19년 전 조회 3,068
19년 전 조회 2,705
19년 전 조회 3,115
19년 전 조회 2,888
19년 전 조회 3,651
19년 전 조회 2,012
19년 전 조회 2,859
19년 전 조회 2,518
19년 전 조회 2,150
19년 전 조회 2,569
19년 전 조회 1,997
19년 전 조회 5,559
19년 전 조회 2,405
19년 전 조회 4,368
19년 전 조회 2,434
19년 전 조회 1,994
19년 전 조회 2,721
19년 전 조회 2,469
19년 전 조회 2,657
19년 전 조회 2,309
19년 전 조회 4,060
19년 전 조회 3,538
19년 전 조회 2,324
19년 전 조회 2,250
19년 전 조회 2,115
19년 전 조회 2,125
19년 전 조회 4,509
19년 전 조회 3,478
19년 전 조회 2,907
19년 전 조회 3,486
19년 전 조회 3,122
19년 전 조회 2,975
19년 전 조회 2,476
19년 전 조회 2,290
19년 전 조회 2,618
19년 전 조회 3,227
19년 전 조회 2,244
19년 전 조회 3,240
19년 전 조회 3,378
19년 전 조회 3,042
19년 전 조회 2,064
19년 전 조회 1,818
19년 전 조회 2,453
19년 전 조회 2,373
19년 전 조회 1,730
19년 전 조회 1,785
19년 전 조회 1,689
19년 전 조회 2,181
19년 전 조회 1,760
19년 전 조회 2,304
19년 전 조회 2,037
19년 전 조회 1,916
19년 전 조회 1,781
19년 전 조회 1,966
19년 전 조회 2,015
19년 전 조회 2,062
19년 전 조회 2,808
19년 전 조회 5,442
19년 전 조회 1,845
19년 전 조회 1,694
19년 전 조회 1,548
19년 전 조회 1,714
19년 전 조회 1,653
19년 전 조회 1,565
19년 전 조회 1,576
19년 전 조회 1,493
19년 전 조회 1,565
19년 전 조회 2,922
19년 전 조회 3,946