콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,238
19년 전 조회 3,298
19년 전 조회 3,042
19년 전 조회 4,872
19년 전 조회 2,703
19년 전 조회 3,314
19년 전 조회 3,149
19년 전 조회 1,997
19년 전 조회 3,136
19년 전 조회 1,879
19년 전 조회 2,342
19년 전 조회 2,416
19년 전 조회 3,995
19년 전 조회 3,182
19년 전 조회 3,110
19년 전 조회 2,549
19년 전 조회 2,011
19년 전 조회 1,652
19년 전 조회 2,425
19년 전 조회 2,343
19년 전 조회 1,828
19년 전 조회 1,827
19년 전 조회 2,615
19년 전 조회 2,588
19년 전 조회 1,891
19년 전 조회 2,122
19년 전 조회 3,308
19년 전 조회 1,959
19년 전 조회 2,501
19년 전 조회 2,580
19년 전 조회 2,675
19년 전 조회 2,948
19년 전 조회 2,571
19년 전 조회 2,988
19년 전 조회 2,771
19년 전 조회 3,525
19년 전 조회 1,884
19년 전 조회 2,743
19년 전 조회 2,380
19년 전 조회 2,031
19년 전 조회 2,433
19년 전 조회 1,890
19년 전 조회 5,451
19년 전 조회 2,273
19년 전 조회 4,256
19년 전 조회 2,312
19년 전 조회 1,862
19년 전 조회 2,603
19년 전 조회 2,344
19년 전 조회 2,539
19년 전 조회 2,181
19년 전 조회 3,924
19년 전 조회 3,426
19년 전 조회 2,208
19년 전 조회 2,119
19년 전 조회 1,987
19년 전 조회 2,007
19년 전 조회 4,386
19년 전 조회 3,363
19년 전 조회 2,781
19년 전 조회 3,363
19년 전 조회 3,009
19년 전 조회 2,851
19년 전 조회 2,352
19년 전 조회 2,173
19년 전 조회 2,503
19년 전 조회 3,110
19년 전 조회 2,135
19년 전 조회 3,127
19년 전 조회 3,259
19년 전 조회 2,931
19년 전 조회 1,950
19년 전 조회 1,714
19년 전 조회 2,329
19년 전 조회 2,261
19년 전 조회 1,634
19년 전 조회 1,667
19년 전 조회 1,571
19년 전 조회 2,084
19년 전 조회 1,633
19년 전 조회 2,191
19년 전 조회 1,921
19년 전 조회 1,819
19년 전 조회 1,661
19년 전 조회 1,849
19년 전 조회 1,900
19년 전 조회 1,955
19년 전 조회 2,704
19년 전 조회 5,325
19년 전 조회 1,733
19년 전 조회 1,581
19년 전 조회 1,442
19년 전 조회 1,603
19년 전 조회 1,536
19년 전 조회 1,456
19년 전 조회 1,466
19년 전 조회 1,387
19년 전 조회 1,451
19년 전 조회 2,814
19년 전 조회 3,833