콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,255
19년 전 조회 3,317
19년 전 조회 3,058
19년 전 조회 4,887
19년 전 조회 2,734
19년 전 조회 3,341
19년 전 조회 3,168
19년 전 조회 2,024
19년 전 조회 3,160
19년 전 조회 1,903
19년 전 조회 2,379
19년 전 조회 2,443
19년 전 조회 4,016
19년 전 조회 3,223
19년 전 조회 3,139
19년 전 조회 2,573
19년 전 조회 2,044
19년 전 조회 1,682
19년 전 조회 2,465
19년 전 조회 2,366
19년 전 조회 1,853
19년 전 조회 1,850
19년 전 조회 2,650
19년 전 조회 2,619
19년 전 조회 1,915
19년 전 조회 2,148
19년 전 조회 3,342
19년 전 조회 1,985
19년 전 조회 2,514
19년 전 조회 2,599
19년 전 조회 2,697
19년 전 조회 2,973
19년 전 조회 2,602
19년 전 조회 3,006
19년 전 조회 2,784
19년 전 조회 3,552
19년 전 조회 1,911
19년 전 조회 2,765
19년 전 조회 2,411
19년 전 조회 2,051
19년 전 조회 2,471
19년 전 조회 1,899
19년 전 조회 5,462
19년 전 조회 2,312
19년 전 조회 4,265
19년 전 조회 2,335
19년 전 조회 1,886
19년 전 조회 2,639
19년 전 조회 2,386
19년 전 조회 2,579
19년 전 조회 2,207
19년 전 조회 3,966
19년 전 조회 3,466
19년 전 조회 2,229
19년 전 조회 2,140
19년 전 조회 2,010
19년 전 조회 2,041
19년 전 조회 4,414
19년 전 조회 3,380
19년 전 조회 2,812
19년 전 조회 3,379
19년 전 조회 3,041
19년 전 조회 2,878
19년 전 조회 2,368
19년 전 조회 2,198
19년 전 조회 2,521
19년 전 조회 3,141
19년 전 조회 2,150
19년 전 조회 3,138
19년 전 조회 3,289
19년 전 조회 2,949
19년 전 조회 1,970
19년 전 조회 1,730
19년 전 조회 2,361
19년 전 조회 2,277
19년 전 조회 1,644
19년 전 조회 1,699
19년 전 조회 1,598
19년 전 조회 2,098
19년 전 조회 1,653
19년 전 조회 2,215
19년 전 조회 1,939
19년 전 조회 1,833
19년 전 조회 1,677
19년 전 조회 1,878
19년 전 조회 1,926
19년 전 조회 1,969
19년 전 조회 2,719
19년 전 조회 5,348
19년 전 조회 1,745
19년 전 조회 1,603
19년 전 조회 1,457
19년 전 조회 1,619
19년 전 조회 1,567
19년 전 조회 1,476
19년 전 조회 1,484
19년 전 조회 1,401
19년 전 조회 1,481
19년 전 조회 2,828
19년 전 조회 3,843