콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,359
19년 전 조회 3,436
19년 전 조회 3,154
19년 전 조회 4,994
19년 전 조회 2,831
19년 전 조회 3,445
19년 전 조회 3,270
19년 전 조회 2,142
19년 전 조회 3,264
19년 전 조회 2,004
19년 전 조회 2,462
19년 전 조회 2,547
19년 전 조회 4,115
19년 전 조회 3,307
19년 전 조회 3,226
19년 전 조회 2,671
19년 전 조회 2,141
19년 전 조회 1,782
19년 전 조회 2,554
19년 전 조회 2,471
19년 전 조회 1,942
19년 전 조회 1,957
19년 전 조회 2,733
19년 전 조회 2,700
19년 전 조회 2,020
19년 전 조회 2,243
19년 전 조회 3,427
19년 전 조회 2,072
19년 전 조회 2,607
19년 전 조회 2,683
19년 전 조회 2,798
19년 전 조회 3,061
19년 전 조회 2,700
19년 전 조회 3,108
19년 전 조회 2,881
19년 전 조회 3,647
19년 전 조회 2,004
19년 전 조회 2,852
19년 전 조회 2,513
19년 전 조회 2,141
19년 전 조회 2,562
19년 전 조회 1,989
19년 전 조회 5,553
19년 전 조회 2,397
19년 전 조회 4,363
19년 전 조회 2,427
19년 전 조회 1,988
19년 전 조회 2,713
19년 전 조회 2,459
19년 전 조회 2,652
19년 전 조회 2,305
19년 전 조회 4,054
19년 전 조회 3,534
19년 전 조회 2,321
19년 전 조회 2,243
19년 전 조회 2,111
19년 전 조회 2,115
19년 전 조회 4,504
19년 전 조회 3,473
19년 전 조회 2,901
19년 전 조회 3,479
19년 전 조회 3,118
19년 전 조회 2,966
19년 전 조회 2,472
19년 전 조회 2,288
19년 전 조회 2,615
19년 전 조회 3,217
19년 전 조회 2,237
19년 전 조회 3,236
19년 전 조회 3,370
19년 전 조회 3,036
19년 전 조회 2,061
19년 전 조회 1,813
19년 전 조회 2,448
19년 전 조회 2,366
19년 전 조회 1,726
19년 전 조회 1,782
19년 전 조회 1,682
19년 전 조회 2,174
19년 전 조회 1,751
19년 전 조회 2,299
19년 전 조회 2,029
19년 전 조회 1,911
19년 전 조회 1,773
19년 전 조회 1,963
19년 전 조회 2,006
19년 전 조회 2,057
19년 전 조회 2,804
19년 전 조회 5,436
19년 전 조회 1,839
19년 전 조회 1,686
19년 전 조회 1,541
19년 전 조회 1,705
19년 전 조회 1,645
19년 전 조회 1,562
19년 전 조회 1,568
19년 전 조회 1,486
19년 전 조회 1,561
19년 전 조회 2,916
19년 전 조회 3,938