콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,243
19년 전 조회 3,301
19년 전 조회 3,046
19년 전 조회 4,874
19년 전 조회 2,706
19년 전 조회 3,315
19년 전 조회 3,151
19년 전 조회 2,002
19년 전 조회 3,140
19년 전 조회 1,881
19년 전 조회 2,348
19년 전 조회 2,421
19년 전 조회 3,998
19년 전 조회 3,190
19년 전 조회 3,115
19년 전 조회 2,554
19년 전 조회 2,013
19년 전 조회 1,656
19년 전 조회 2,428
19년 전 조회 2,349
19년 전 조회 1,828
19년 전 조회 1,831
19년 전 조회 2,619
19년 전 조회 2,593
19년 전 조회 1,895
19년 전 조회 2,125
19년 전 조회 3,313
19년 전 조회 1,964
19년 전 조회 2,506
19년 전 조회 2,582
19년 전 조회 2,677
19년 전 조회 2,951
19년 전 조회 2,579
19년 전 조회 2,990
19년 전 조회 2,773
19년 전 조회 3,528
19년 전 조회 1,892
19년 전 조회 2,745
19년 전 조회 2,386
19년 전 조회 2,034
19년 전 조회 2,435
19년 전 조회 1,892
19년 전 조회 5,452
19년 전 조회 2,278
19년 전 조회 4,259
19년 전 조회 2,314
19년 전 조회 1,865
19년 전 조회 2,606
19년 전 조회 2,348
19년 전 조회 2,544
19년 전 조회 2,182
19년 전 조회 3,929
19년 전 조회 3,429
19년 전 조회 2,213
19년 전 조회 2,124
19년 전 조회 1,989
19년 전 조회 2,011
19년 전 조회 4,388
19년 전 조회 3,367
19년 전 조회 2,785
19년 전 조회 3,366
19년 전 조회 3,013
19년 전 조회 2,855
19년 전 조회 2,353
19년 전 조회 2,178
19년 전 조회 2,506
19년 전 조회 3,112
19년 전 조회 2,139
19년 전 조회 3,129
19년 전 조회 3,262
19년 전 조회 2,933
19년 전 조회 1,953
19년 전 조회 1,715
19년 전 조회 2,335
19년 전 조회 2,264
19년 전 조회 1,636
19년 전 조회 1,669
19년 전 조회 1,574
19년 전 조회 2,084
19년 전 조회 1,638
19년 전 조회 2,194
19년 전 조회 1,925
19년 전 조회 1,822
19년 전 조회 1,663
19년 전 조회 1,850
19년 전 조회 1,903
19년 전 조회 1,956
19년 전 조회 2,706
19년 전 조회 5,327
19년 전 조회 1,734
19년 전 조회 1,584
19년 전 조회 1,446
19년 전 조회 1,607
19년 전 조회 1,538
19년 전 조회 1,459
19년 전 조회 1,471
19년 전 조회 1,388
19년 전 조회 1,455
19년 전 조회 2,814
19년 전 조회 3,833