콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,318
19년 전 조회 3,389
19년 전 조회 3,122
19년 전 조회 4,956
19년 전 조회 2,800
19년 전 조회 3,419
19년 전 조회 3,240
19년 전 조회 2,091
19년 전 조회 3,229
19년 전 조회 1,965
19년 전 조회 2,434
19년 전 조회 2,506
19년 전 조회 4,078
19년 전 조회 3,269
19년 전 조회 3,187
19년 전 조회 2,628
19년 전 조회 2,107
19년 전 조회 1,749
19년 전 조회 2,516
19년 전 조회 2,428
19년 전 조회 1,909
19년 전 조회 1,910
19년 전 조회 2,701
19년 전 조회 2,663
19년 전 조회 1,988
19년 전 조회 2,206
19년 전 조회 3,388
19년 전 조회 2,040
19년 전 조회 2,578
19년 전 조회 2,653
19년 전 조회 2,761
19년 전 조회 3,020
19년 전 조회 2,662
19년 전 조회 3,077
19년 전 조회 2,844
19년 전 조회 3,617
19년 전 조회 1,968
19년 전 조회 2,828
19년 전 조회 2,469
19년 전 조회 2,109
19년 전 조회 2,525
19년 전 조회 1,952
19년 전 조회 5,520
19년 전 조회 2,360
19년 전 조회 4,329
19년 전 조회 2,395
19년 전 조회 1,947
19년 전 조회 2,689
19년 전 조회 2,422
19년 전 조회 2,617
19년 전 조회 2,275
19년 전 조회 4,015
19년 전 조회 3,503
19년 전 조회 2,283
19년 전 조회 2,207
19년 전 조회 2,073
19년 전 조회 2,079
19년 전 조회 4,466
19년 전 조회 3,440
19년 전 조회 2,866
19년 전 조회 3,446
19년 전 조회 3,089
19년 전 조회 2,936
19년 전 조회 2,433
19년 전 조회 2,252
19년 전 조회 2,575
19년 전 조회 3,184
19년 전 조회 2,201
19년 전 조회 3,206
19년 전 조회 3,330
19년 전 조회 3,001
19년 전 조회 2,031
19년 전 조회 1,784
19년 전 조회 2,412
19년 전 조회 2,333
19년 전 조회 1,697
19년 전 조회 1,738
19년 전 조회 1,643
19년 전 조회 2,145
19년 전 조회 1,708
19년 전 조회 2,266
19년 전 조회 1,994
19년 전 조회 1,887
19년 전 조회 1,734
19년 전 조회 1,929
19년 전 조회 1,976
19년 전 조회 2,024
19년 전 조회 2,766
19년 전 조회 5,401
19년 전 조회 1,811
19년 전 조회 1,656
19년 전 조회 1,508
19년 전 조회 1,671
19년 전 조회 1,614
19년 전 조회 1,528
19년 전 조회 1,530
19년 전 조회 1,452
19년 전 조회 1,526
19년 전 조회 2,880
19년 전 조회 3,896