콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,319
19년 전 조회 3,394
19년 전 조회 3,123
19년 전 조회 4,959
19년 전 조회 2,802
19년 전 조회 3,422
19년 전 조회 3,242
19년 전 조회 2,094
19년 전 조회 3,230
19년 전 조회 1,966
19년 전 조회 2,436
19년 전 조회 2,508
19년 전 조회 4,080
19년 전 조회 3,272
19년 전 조회 3,192
19년 전 조회 2,632
19년 전 조회 2,111
19년 전 조회 1,751
19년 전 조회 2,519
19년 전 조회 2,429
19년 전 조회 1,910
19년 전 조회 1,912
19년 전 조회 2,702
19년 전 조회 2,665
19년 전 조회 1,988
19년 전 조회 2,208
19년 전 조회 3,392
19년 전 조회 2,043
19년 전 조회 2,579
19년 전 조회 2,657
19년 전 조회 2,763
19년 전 조회 3,022
19년 전 조회 2,666
19년 전 조회 3,080
19년 전 조회 2,846
19년 전 조회 3,620
19년 전 조회 1,971
19년 전 조회 2,831
19년 전 조회 2,473
19년 전 조회 2,110
19년 전 조회 2,528
19년 전 조회 1,954
19년 전 조회 5,523
19년 전 조회 2,361
19년 전 조회 4,333
19년 전 조회 2,398
19년 전 조회 1,950
19년 전 조회 2,690
19년 전 조회 2,424
19년 전 조회 2,618
19년 전 조회 2,276
19년 전 조회 4,016
19년 전 조회 3,507
19년 전 조회 2,288
19년 전 조회 2,208
19년 전 조회 2,077
19년 전 조회 2,081
19년 전 조회 4,468
19년 전 조회 3,444
19년 전 조회 2,869
19년 전 조회 3,447
19년 전 조회 3,091
19년 전 조회 2,939
19년 전 조회 2,437
19년 전 조회 2,255
19년 전 조회 2,576
19년 전 조회 3,188
19년 전 조회 2,205
19년 전 조회 3,209
19년 전 조회 3,334
19년 전 조회 3,002
19년 전 조회 2,033
19년 전 조회 1,784
19년 전 조회 2,414
19년 전 조회 2,337
19년 전 조회 1,698
19년 전 조회 1,740
19년 전 조회 1,646
19년 전 조회 2,146
19년 전 조회 1,709
19년 전 조회 2,267
19년 전 조회 1,996
19년 전 조회 1,889
19년 전 조회 1,738
19년 전 조회 1,932
19년 전 조회 1,978
19년 전 조회 2,026
19년 전 조회 2,768
19년 전 조회 5,401
19년 전 조회 1,814
19년 전 조회 1,657
19년 전 조회 1,512
19년 전 조회 1,673
19년 전 조회 1,614
19년 전 조회 1,529
19년 전 조회 1,536
19년 전 조회 1,452
19년 전 조회 1,527
19년 전 조회 2,881
19년 전 조회 3,900