콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,474
19년 전 조회 3,537
19년 전 조회 3,270
19년 전 조회 5,093
19년 전 조회 2,941
19년 전 조회 3,547
19년 전 조회 3,374
19년 전 조회 2,241
19년 전 조회 3,361
19년 전 조회 2,113
19년 전 조회 2,562
19년 전 조회 2,643
19년 전 조회 4,225
19년 전 조회 3,412
19년 전 조회 3,326
19년 전 조회 2,764
19년 전 조회 2,229
19년 전 조회 1,879
19년 전 조회 2,659
19년 전 조회 2,568
19년 전 조회 2,040
19년 전 조회 2,051
19년 전 조회 2,837
19년 전 조회 2,790
19년 전 조회 2,111
19년 전 조회 2,339
19년 전 조회 3,530
19년 전 조회 2,186
19년 전 조회 2,706
19년 전 조회 2,785
19년 전 조회 2,905
19년 전 조회 3,166
19년 전 조회 2,797
19년 전 조회 3,212
19년 전 조회 2,983
19년 전 조회 3,739
19년 전 조회 2,099
19년 전 조회 2,963
19년 전 조회 2,610
19년 전 조회 2,251
19년 전 조회 2,653
19년 전 조회 2,096
19년 전 조회 5,665
19년 전 조회 2,500
19년 전 조회 4,469
19년 전 조회 2,540
19년 전 조회 2,089
19년 전 조회 2,822
19년 전 조회 2,568
19년 전 조회 2,741
19년 전 조회 2,406
19년 전 조회 4,155
19년 전 조회 3,639
19년 전 조회 2,417
19년 전 조회 2,350
19년 전 조회 2,205
19년 전 조회 2,206
19년 전 조회 4,607
19년 전 조회 3,579
19년 전 조회 3,001
19년 전 조회 3,591
19년 전 조회 3,214
19년 전 조회 3,064
19년 전 조회 2,576
19년 전 조회 2,392
19년 전 조회 2,717
19년 전 조회 3,318
19년 전 조회 2,335
19년 전 조회 3,347
19년 전 조회 3,463
19년 전 조회 3,130
19년 전 조회 2,152
19년 전 조회 1,926
19년 전 조회 2,548
19년 전 조회 2,474
19년 전 조회 1,839
19년 전 조회 1,867
19년 전 조회 1,774
19년 전 조회 2,277
19년 전 조회 1,843
19년 전 조회 2,391
19년 전 조회 2,135
19년 전 조회 2,031
19년 전 조회 1,873
19년 전 조회 2,057
19년 전 조회 2,100
19년 전 조회 2,156
19년 전 조회 2,888
19년 전 조회 5,524
19년 전 조회 1,943
19년 전 조회 1,784
19년 전 조회 1,642
19년 전 조회 1,809
19년 전 조회 1,740
19년 전 조회 1,658
19년 전 조회 1,691
19년 전 조회 1,596
19년 전 조회 1,654
19년 전 조회 3,014
19년 전 조회 4,035