콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,372
19년 전 조회 3,447
19년 전 조회 3,167
19년 전 조회 5,003
19년 전 조회 2,843
19년 전 조회 3,457
19년 전 조회 3,287
19년 전 조회 2,152
19년 전 조회 3,278
19년 전 조회 2,016
19년 전 조회 2,474
19년 전 조회 2,559
19년 전 조회 4,129
19년 전 조회 3,319
19년 전 조회 3,237
19년 전 조회 2,684
19년 전 조회 2,149
19년 전 조회 1,789
19년 전 조회 2,572
19년 전 조회 2,480
19년 전 조회 1,954
19년 전 조회 1,963
19년 전 조회 2,744
19년 전 조회 2,709
19년 전 조회 2,028
19년 전 조회 2,254
19년 전 조회 3,437
19년 전 조회 2,089
19년 전 조회 2,619
19년 전 조회 2,697
19년 전 조회 2,812
19년 전 조회 3,073
19년 전 조회 2,713
19년 전 조회 3,122
19년 전 조회 2,891
19년 전 조회 3,657
19년 전 조회 2,014
19년 전 조회 2,863
19년 전 조회 2,524
19년 전 조회 2,157
19년 전 조회 2,577
19년 전 조회 2,002
19년 전 조회 5,565
19년 전 조회 2,411
19년 전 조회 4,374
19년 전 조회 2,445
19년 전 조회 2,000
19년 전 조회 2,731
19년 전 조회 2,475
19년 전 조회 2,664
19년 전 조회 2,317
19년 전 조회 4,069
19년 전 조회 3,545
19년 전 조회 2,328
19년 전 조회 2,261
19년 전 조회 2,120
19년 전 조회 2,131
19년 전 조회 4,518
19년 전 조회 3,482
19년 전 조회 2,912
19년 전 조회 3,494
19년 전 조회 3,131
19년 전 조회 2,980
19년 전 조회 2,483
19년 전 조회 2,297
19년 전 조회 2,623
19년 전 조회 3,236
19년 전 조회 2,256
19년 전 조회 3,248
19년 전 조회 3,386
19년 전 조회 3,050
19년 전 조회 2,073
19년 전 조회 1,824
19년 전 조회 2,461
19년 전 조회 2,383
19년 전 조회 1,742
19년 전 조회 1,787
19년 전 조회 1,693
19년 전 조회 2,189
19년 전 조회 1,763
19년 전 조회 2,311
19년 전 조회 2,040
19년 전 조회 1,928
19년 전 조회 1,790
19년 전 조회 1,976
19년 전 조회 2,020
19년 전 조회 2,068
19년 전 조회 2,810
19년 전 조회 5,446
19년 전 조회 1,854
19년 전 조회 1,700
19년 전 조회 1,559
19년 전 조회 1,719
19년 전 조회 1,656
19년 전 조회 1,571
19년 전 조회 1,584
19년 전 조회 1,502
19년 전 조회 1,571
19년 전 조회 2,931
19년 전 조회 3,953