콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,412
19년 전 조회 3,485
19년 전 조회 3,213
19년 전 조회 5,037
19년 전 조회 2,878
19년 전 조회 3,495
19년 전 조회 3,324
19년 전 조회 2,185
19년 전 조회 3,319
19년 전 조회 2,061
19년 전 조회 2,513
19년 전 조회 2,602
19년 전 조회 4,171
19년 전 조회 3,368
19년 전 조회 3,275
19년 전 조회 2,722
19년 전 조회 2,188
19년 전 조회 1,825
19년 전 조회 2,614
19년 전 조회 2,524
19년 전 조회 2,001
19년 전 조회 1,997
19년 전 조회 2,786
19년 전 조회 2,748
19년 전 조회 2,072
19년 전 조회 2,297
19년 전 조회 3,473
19년 전 조회 2,137
19년 전 조회 2,656
19년 전 조회 2,734
19년 전 조회 2,859
19년 전 조회 3,116
19년 전 조회 2,760
19년 전 조회 3,166
19년 전 조회 2,943
19년 전 조회 3,689
19년 전 조회 2,055
19년 전 조회 2,909
19년 전 조회 2,565
19년 전 조회 2,204
19년 전 조회 2,610
19년 전 조회 2,047
19년 전 조회 5,613
19년 전 조회 2,462
19년 전 조회 4,412
19년 전 조회 2,487
19년 전 조회 2,042
19년 전 조회 2,772
19년 전 조회 2,526
19년 전 조회 2,700
19년 전 조회 2,355
19년 전 조회 4,104
19년 전 조회 3,589
19년 전 조회 2,369
19년 전 조회 2,298
19년 전 조회 2,165
19년 전 조회 2,168
19년 전 조회 4,564
19년 전 조회 3,527
19년 전 조회 2,943
19년 전 조회 3,533
19년 전 조회 3,171
19년 전 조회 3,022
19년 전 조회 2,535
19년 전 조회 2,333
19년 전 조회 2,657
19년 전 조회 3,266
19년 전 조회 2,290
19년 전 조회 3,292
19년 전 조회 3,420
19년 전 조회 3,085
19년 전 조회 2,114
19년 전 조회 1,865
19년 전 조회 2,498
19년 전 조회 2,421
19년 전 조회 1,782
19년 전 조회 1,831
19년 전 조회 1,735
19년 전 조회 2,232
19년 전 조회 1,801
19년 전 조회 2,344
19년 전 조회 2,090
19년 전 조회 1,969
19년 전 조회 1,830
19년 전 조회 2,014
19년 전 조회 2,052
19년 전 조회 2,107
19년 전 조회 2,847
19년 전 조회 5,491
19년 전 조회 1,893
19년 전 조회 1,746
19년 전 조회 1,594
19년 전 조회 1,764
19년 전 조회 1,699
19년 전 조회 1,623
19년 전 조회 1,628
19년 전 조회 1,548
19년 전 조회 1,607
19년 전 조회 2,971
19년 전 조회 3,988