콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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>년&nbsp;&nbsp;&nbsp;";
}

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>월&nbsp;&nbsp;&nbsp;";
}

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>일&nbsp;&nbsp;&nbsp;";
}

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,225
19년 전 조회 3,285
19년 전 조회 3,021
19년 전 조회 4,856
19년 전 조회 2,686
19년 전 조회 3,299
19년 전 조회 3,129
19년 전 조회 1,980
19년 전 조회 3,120
19년 전 조회 1,861
19년 전 조회 2,330
19년 전 조회 2,401
19년 전 조회 3,979
19년 전 조회 3,166
19년 전 조회 3,089
19년 전 조회 2,534
19년 전 조회 1,994
19년 전 조회 1,637
19년 전 조회 2,404
19년 전 조회 2,326
19년 전 조회 1,815
19년 전 조회 1,811
19년 전 조회 2,600
19년 전 조회 2,574
19년 전 조회 1,873
19년 전 조회 2,105
19년 전 조회 3,291
19년 전 조회 1,945
19년 전 조회 2,490
19년 전 조회 2,562
19년 전 조회 2,655
19년 전 조회 2,933
19년 전 조회 2,559
19년 전 조회 2,973
19년 전 조회 2,757
19년 전 조회 3,509
19년 전 조회 1,865
19년 전 조회 2,729
19년 전 조회 2,367
19년 전 조회 2,017
19년 전 조회 2,424
19년 전 조회 1,868
19년 전 조회 5,437
19년 전 조회 2,254
19년 전 조회 4,239
19년 전 조회 2,293
19년 전 조회 1,843
19년 전 조회 2,586
19년 전 조회 2,326
19년 전 조회 2,525
19년 전 조회 2,161
19년 전 조회 3,909
19년 전 조회 3,414
19년 전 조회 2,197
19년 전 조회 2,104
19년 전 조회 1,969
19년 전 조회 1,988
19년 전 조회 4,367
19년 전 조회 3,346
19년 전 조회 2,770
19년 전 조회 3,344
19년 전 조회 2,996
19년 전 조회 2,836
19년 전 조회 2,338
19년 전 조회 2,158
19년 전 조회 2,483
19년 전 조회 3,092
19년 전 조회 2,118
19년 전 조회 3,112
19년 전 조회 3,244
19년 전 조회 2,915
19년 전 조회 1,935
19년 전 조회 1,698
19년 전 조회 2,315
19년 전 조회 2,250
19년 전 조회 1,621
19년 전 조회 1,656
19년 전 조회 1,559
19년 전 조회 2,065
19년 전 조회 1,610
19년 전 조회 2,177
19년 전 조회 1,907
19년 전 조회 1,797
19년 전 조회 1,644
19년 전 조회 1,835
19년 전 조회 1,884
19년 전 조회 1,939
19년 전 조회 2,686
19년 전 조회 5,313
19년 전 조회 1,718
19년 전 조회 1,564
19년 전 조회 1,429
19년 전 조회 1,588
19년 전 조회 1,522
19년 전 조회 1,441
19년 전 조회 1,445
19년 전 조회 1,369
19년 전 조회 1,438
19년 전 조회 2,802
19년 전 조회 3,820
🐛 버그신고