콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,159
19년 전 조회 2,019
19년 전 조회 3,154
19년 전 조회 1,895
19년 전 조회 2,370
19년 전 조회 2,434
19년 전 조회 4,009
19년 전 조회 3,214
19년 전 조회 3,129
19년 전 조회 2,568
19년 전 조회 2,035
19년 전 조회 1,670
19년 전 조회 2,451
19년 전 조회 2,359
19년 전 조회 1,846
19년 전 조회 1,843
19년 전 조회 2,639
19년 전 조회 2,612
19년 전 조회 1,907
19년 전 조회 2,139
19년 전 조회 3,333
19년 전 조회 1,978
19년 전 조회 2,514
19년 전 조회 2,595
19년 전 조회 2,691
19년 전 조회 2,966
19년 전 조회 2,592
19년 전 조회 3,004
19년 전 조회 2,778
19년 전 조회 3,543
19년 전 조회 1,904
19년 전 조회 2,761
19년 전 조회 2,401
19년 전 조회 2,045
19년 전 조회 2,460
19년 전 조회 1,898
19년 전 조회 5,459
19년 전 조회 2,302
19년 전 조회 4,263
19년 전 조회 2,329
19년 전 조회 1,876
19년 전 조회 2,630
19년 전 조회 2,376
19년 전 조회 2,568
19년 전 조회 2,197
19년 전 조회 3,951
19년 전 조회 3,456
19년 전 조회 2,223
19년 전 조회 2,135
19년 전 조회 2,001
19년 전 조회 2,035
19년 전 조회 4,407
19년 전 조회 3,374
19년 전 조회 2,806
19년 전 조회 3,376
19년 전 조회 3,031
19년 전 조회 2,873
19년 전 조회 2,366
19년 전 조회 2,195
19년 전 조회 2,519
19년 전 조회 3,131
19년 전 조회 2,147
19년 전 조회 3,137
19년 전 조회 3,282
19년 전 조회 2,942
19년 전 조회 1,965
19년 전 조회 1,725
19년 전 조회 2,353
19년 전 조회 2,272
19년 전 조회 1,643
19년 전 조회 1,690
19년 전 조회 1,592
19년 전 조회 2,092
19년 전 조회 1,647
19년 전 조회 2,209
19년 전 조회 1,932
19년 전 조회 1,832
19년 전 조회 1,674
19년 전 조회 1,871
19년 전 조회 1,919
19년 전 조회 1,965
19년 전 조회 2,715
19년 전 조회 5,340
19년 전 조회 1,742
19년 전 조회 1,600
19년 전 조회 1,452
19년 전 조회 1,615
19년 전 조회 1,555
19년 전 조회 1,474
19년 전 조회 1,482
19년 전 조회 1,395
19년 전 조회 1,473
19년 전 조회 2,823
19년 전 조회 3,840