콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,424
19년 전 조회 3,495
19년 전 조회 3,226
19년 전 조회 5,051
19년 전 조회 2,886
19년 전 조회 3,511
19년 전 조회 3,339
19년 전 조회 2,194
19년 전 조회 3,328
19년 전 조회 2,075
19년 전 조회 2,523
19년 전 조회 2,608
19년 전 조회 4,187
19년 전 조회 3,379
19년 전 조회 3,288
19년 전 조회 2,734
19년 전 조회 2,198
19년 전 조회 1,839
19년 전 조회 2,623
19년 전 조회 2,535
19년 전 조회 2,013
19년 전 조회 2,015
19년 전 조회 2,796
19년 전 조회 2,760
19년 전 조회 2,083
19년 전 조회 2,306
19년 전 조회 3,483
19년 전 조회 2,145
19년 전 조회 2,672
19년 전 조회 2,744
19년 전 조회 2,871
19년 전 조회 3,132
19년 전 조회 2,764
19년 전 조회 3,181
19년 전 조회 2,951
19년 전 조회 3,699
19년 전 조회 2,067
19년 전 조회 2,927
19년 전 조회 2,574
19년 전 조회 2,213
19년 전 조회 2,623
19년 전 조회 2,056
19년 전 조회 5,624
19년 전 조회 2,474
19년 전 조회 4,423
19년 전 조회 2,501
19년 전 조회 2,052
19년 전 조회 2,781
19년 전 조회 2,535
19년 전 조회 2,712
19년 전 조회 2,369
19년 전 조회 4,117
19년 전 조회 3,603
19년 전 조회 2,379
19년 전 조회 2,315
19년 전 조회 2,181
19년 전 조회 2,177
19년 전 조회 4,574
19년 전 조회 3,537
19년 전 조회 2,959
19년 전 조회 3,541
19년 전 조회 3,180
19년 전 조회 3,036
19년 전 조회 2,541
19년 전 조회 2,348
19년 전 조회 2,670
19년 전 조회 3,275
19년 전 조회 2,301
19년 전 조회 3,300
19년 전 조회 3,432
19년 전 조회 3,101
19년 전 조회 2,126
19년 전 조회 1,880
19년 전 조회 2,507
19년 전 조회 2,434
19년 전 조회 1,796
19년 전 조회 1,841
19년 전 조회 1,745
19년 전 조회 2,243
19년 전 조회 1,810
19년 전 조회 2,365
19년 전 조회 2,100
19년 전 조회 1,980
19년 전 조회 1,841
19년 전 조회 2,022
19년 전 조회 2,070
19년 전 조회 2,117
19년 전 조회 2,859
19년 전 조회 5,499
19년 전 조회 1,901
19년 전 조회 1,754
19년 전 조회 1,605
19년 전 조회 1,774
19년 전 조회 1,710
19년 전 조회 1,635
19년 전 조회 1,640
19년 전 조회 1,560
19년 전 조회 1,621
19년 전 조회 2,983
19년 전 조회 3,999