콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,379
19년 전 조회 3,455
19년 전 조회 3,172
19년 전 조회 5,010
19년 전 조회 2,849
19년 전 조회 3,465
19년 전 조회 3,295
19년 전 조회 2,155
19년 전 조회 3,289
19년 전 조회 2,022
19년 전 조회 2,480
19년 전 조회 2,565
19년 전 조회 4,135
19년 전 조회 3,324
19년 전 조회 3,245
19년 전 조회 2,688
19년 전 조회 2,154
19년 전 조회 1,798
19년 전 조회 2,579
19년 전 조회 2,485
19년 전 조회 1,960
19년 전 조회 1,968
19년 전 조회 2,751
19년 전 조회 2,719
19년 전 조회 2,038
19년 전 조회 2,261
19년 전 조회 3,444
19년 전 조회 2,096
19년 전 조회 2,623
19년 전 조회 2,704
19년 전 조회 2,818
19년 전 조회 3,079
19년 전 조회 2,724
19년 전 조회 3,130
19년 전 조회 2,899
19년 전 조회 3,665
19년 전 조회 2,020
19년 전 조회 2,869
19년 전 조회 2,533
19년 전 조회 2,162
19년 전 조회 2,582
19년 전 조회 2,012
19년 전 조회 5,570
19년 전 조회 2,420
19년 전 조회 4,379
19년 전 조회 2,447
19년 전 조회 2,010
19년 전 조회 2,735
19년 전 조회 2,482
19년 전 조회 2,668
19년 전 조회 2,325
19년 전 조회 4,077
19년 전 조회 3,552
19년 전 조회 2,333
19년 전 조회 2,266
19년 전 조회 2,131
19년 전 조회 2,134
19년 전 조회 4,527
19년 전 조회 3,495
19년 전 조회 2,916
19년 전 조회 3,502
19년 전 조회 3,139
19년 전 조회 2,989
19년 전 조회 2,489
19년 전 조회 2,302
19년 전 조회 2,632
19년 전 조회 3,238
19년 전 조회 2,261
19년 전 조회 3,255
19년 전 조회 3,389
19년 전 조회 3,055
19년 전 조회 2,079
19년 전 조회 1,831
19년 전 조회 2,466
19년 전 조회 2,390
19년 전 조회 1,748
19년 전 조회 1,796
19년 전 조회 1,698
19년 전 조회 2,195
19년 전 조회 1,769
19년 전 조회 2,314
19년 전 조회 2,051
19년 전 조회 1,934
19년 전 조회 1,800
19년 전 조회 1,984
19년 전 조회 2,024
19년 전 조회 2,074
19년 전 조회 2,819
19년 전 조회 5,454
19년 전 조회 1,859
19년 전 조회 1,708
19년 전 조회 1,561
19년 전 조회 1,727
19년 전 조회 1,660
19년 전 조회 1,580
19년 전 조회 1,589
19년 전 조회 1,509
19년 전 조회 1,575
19년 전 조회 2,935
19년 전 조회 3,958