콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,252
19년 전 조회 3,313
19년 전 조회 3,055
19년 전 조회 4,883
19년 전 조회 2,725
19년 전 조회 3,334
19년 전 조회 3,160
19년 전 조회 2,020
19년 전 조회 3,154
19년 전 조회 1,897
19년 전 조회 2,370
19년 전 조회 2,435
19년 전 조회 4,010
19년 전 조회 3,216
19년 전 조회 3,130
19년 전 조회 2,568
19년 전 조회 2,036
19년 전 조회 1,670
19년 전 조회 2,455
19년 전 조회 2,360
19년 전 조회 1,846
19년 전 조회 1,843
19년 전 조회 2,639
19년 전 조회 2,613
19년 전 조회 1,909
19년 전 조회 2,140
19년 전 조회 3,335
19년 전 조회 1,978
19년 전 조회 2,514
19년 전 조회 2,595
19년 전 조회 2,693
19년 전 조회 2,967
19년 전 조회 2,592
19년 전 조회 3,004
19년 전 조회 2,778
19년 전 조회 3,543
19년 전 조회 1,905
19년 전 조회 2,761
19년 전 조회 2,401
19년 전 조회 2,046
19년 전 조회 2,460
19년 전 조회 1,898
19년 전 조회 5,460
19년 전 조회 2,302
19년 전 조회 4,264
19년 전 조회 2,331
19년 전 조회 1,877
19년 전 조회 2,630
19년 전 조회 2,377
19년 전 조회 2,569
19년 전 조회 2,198
19년 전 조회 3,952
19년 전 조회 3,456
19년 전 조회 2,223
19년 전 조회 2,135
19년 전 조회 2,002
19년 전 조회 2,035
19년 전 조회 4,408
19년 전 조회 3,374
19년 전 조회 2,806
19년 전 조회 3,376
19년 전 조회 3,032
19년 전 조회 2,874
19년 전 조회 2,366
19년 전 조회 2,195
19년 전 조회 2,519
19년 전 조회 3,132
19년 전 조회 2,148
19년 전 조회 3,137
19년 전 조회 3,283
19년 전 조회 2,943
19년 전 조회 1,965
19년 전 조회 1,726
19년 전 조회 2,354
19년 전 조회 2,272
19년 전 조회 1,643
19년 전 조회 1,691
19년 전 조회 1,594
19년 전 조회 2,092
19년 전 조회 1,648
19년 전 조회 2,210
19년 전 조회 1,934
19년 전 조회 1,832
19년 전 조회 1,675
19년 전 조회 1,871
19년 전 조회 1,920
19년 전 조회 1,965
19년 전 조회 2,715
19년 전 조회 5,340
19년 전 조회 1,742
19년 전 조회 1,600
19년 전 조회 1,453
19년 전 조회 1,615
19년 전 조회 1,559
19년 전 조회 1,474
19년 전 조회 1,482
19년 전 조회 1,396
19년 전 조회 1,475
19년 전 조회 2,823
19년 전 조회 3,840