콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,390
19년 전 조회 3,463
19년 전 조회 3,186
19년 전 조회 5,020
19년 전 조회 2,860
19년 전 조회 3,474
19년 전 조회 3,308
19년 전 조회 2,164
19년 전 조회 3,299
19년 전 조회 2,033
19년 전 조회 2,493
19년 전 조회 2,579
19년 전 조회 4,149
19년 전 조회 3,341
19년 전 조회 3,254
19년 전 조회 2,702
19년 전 조회 2,169
19년 전 조회 1,805
19년 전 조회 2,591
19년 전 조회 2,496
19년 전 조회 1,975
19년 전 조회 1,977
19년 전 조회 2,765
19년 전 조회 2,729
19년 전 조회 2,051
19년 전 조회 2,271
19년 전 조회 3,458
19년 전 조회 2,115
19년 전 조회 2,634
19년 전 조회 2,712
19년 전 조회 2,831
19년 전 조회 3,089
19년 전 조회 2,738
19년 전 조회 3,146
19년 전 조회 2,915
19년 전 조회 3,674
19년 전 조회 2,027
19년 전 조회 2,881
19년 전 조회 2,545
19년 전 조회 2,175
19년 전 조회 2,592
19년 전 조회 2,024
19년 전 조회 5,588
19년 전 조회 2,433
19년 전 조회 4,393
19년 전 조회 2,461
19년 전 조회 2,023
19년 전 조회 2,750
19년 전 조회 2,494
19년 전 조회 2,679
19년 전 조회 2,339
19년 전 조회 4,087
19년 전 조회 3,566
19년 전 조회 2,345
19년 전 조회 2,275
19년 전 조회 2,143
19년 전 조회 2,144
19년 전 조회 4,542
19년 전 조회 3,509
19년 전 조회 2,922
19년 전 조회 3,511
19년 전 조회 3,152
19년 전 조회 3,001
19년 전 조회 2,506
19년 전 조회 2,318
19년 전 조회 2,644
19년 전 조회 3,248
19년 전 조회 2,271
19년 전 조회 3,274
19년 전 조회 3,398
19년 전 조회 3,070
19년 전 조회 2,089
19년 전 조회 1,842
19년 전 조회 2,484
19년 전 조회 2,402
19년 전 조회 1,761
19년 전 조회 1,806
19년 전 조회 1,710
19년 전 조회 2,209
19년 전 조회 1,781
19년 전 조회 2,324
19년 전 조회 2,066
19년 전 조회 1,950
19년 전 조회 1,813
19년 전 조회 1,997
19년 전 조회 2,035
19년 전 조회 2,087
19년 전 조회 2,830
19년 전 조회 5,465
19년 전 조회 1,872
19년 전 조회 1,719
19년 전 조회 1,571
19년 전 조회 1,740
19년 전 조회 1,679
19년 전 조회 1,599
19년 전 조회 1,605
19년 전 조회 1,525
19년 전 조회 1,588
19년 전 조회 2,951
19년 전 조회 3,971