콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,571
19년 전 조회 3,636
19년 전 조회 3,381
19년 전 조회 5,193
19년 전 조회 3,019
19년 전 조회 3,628
19년 전 조회 3,464
19년 전 조회 2,323
19년 전 조회 3,437
19년 전 조회 2,190
19년 전 조회 2,637
19년 전 조회 2,740
19년 전 조회 4,311
19년 전 조회 3,503
19년 전 조회 3,393
19년 전 조회 2,847
19년 전 조회 2,303
19년 전 조회 1,940
19년 전 조회 2,723
19년 전 조회 2,630
19년 전 조회 2,112
19년 전 조회 2,117
19년 전 조회 2,920
19년 전 조회 2,868
19년 전 조회 2,179
19년 전 조회 2,418
19년 전 조회 3,608
19년 전 조회 2,262
19년 전 조회 2,786
19년 전 조회 2,867
19년 전 조회 2,986
19년 전 조회 3,241
19년 전 조회 2,873
19년 전 조회 3,311
19년 전 조회 3,065
19년 전 조회 3,809
19년 전 조회 2,183
19년 전 조회 3,037
19년 전 조회 2,676
19년 전 조회 2,321
19년 전 조회 2,724
19년 전 조회 2,187
19년 전 조회 5,747
19년 전 조회 2,573
19년 전 조회 4,548
19년 전 조회 2,639
19년 전 조회 2,173
19년 전 조회 2,895
19년 전 조회 2,647
19년 전 조회 2,828
19년 전 조회 2,468
19년 전 조회 4,225
19년 전 조회 3,698
19년 전 조회 2,500
19년 전 조회 2,429
19년 전 조회 2,276
19년 전 조회 2,297
19년 전 조회 4,668
19년 전 조회 3,646
19년 전 조회 3,070
19년 전 조회 3,655
19년 전 조회 3,274
19년 전 조회 3,138
19년 전 조회 2,643
19년 전 조회 2,460
19년 전 조회 2,783
19년 전 조회 3,378
19년 전 조회 2,398
19년 전 조회 3,424
19년 전 조회 3,527
19년 전 조회 3,210
19년 전 조회 2,223
19년 전 조회 1,993
19년 전 조회 2,618
19년 전 조회 2,553
19년 전 조회 1,909
19년 전 조회 1,948
19년 전 조회 1,843
19년 전 조회 2,347
19년 전 조회 1,905
19년 전 조회 2,470
19년 전 조회 2,213
19년 전 조회 2,099
19년 전 조회 1,945
19년 전 조회 2,120
19년 전 조회 2,165
19년 전 조회 2,221
19년 전 조회 2,955
19년 전 조회 5,596
19년 전 조회 2,011
19년 전 조회 1,850
19년 전 조회 1,713
19년 전 조회 1,886
19년 전 조회 1,801
19년 전 조회 1,729
19년 전 조회 1,759
19년 전 조회 1,664
19년 전 조회 1,713
19년 전 조회 3,081
19년 전 조회 4,113