콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,255
19년 전 조회 3,317
19년 전 조회 3,058
19년 전 조회 4,887
19년 전 조회 2,731
19년 전 조회 3,339
19년 전 조회 3,168
19년 전 조회 2,024
19년 전 조회 3,159
19년 전 조회 1,903
19년 전 조회 2,379
19년 전 조회 2,443
19년 전 조회 4,014
19년 전 조회 3,222
19년 전 조회 3,139
19년 전 조회 2,572
19년 전 조회 2,043
19년 전 조회 1,681
19년 전 조회 2,462
19년 전 조회 2,365
19년 전 조회 1,853
19년 전 조회 1,850
19년 전 조회 2,650
19년 전 조회 2,618
19년 전 조회 1,915
19년 전 조회 2,146
19년 전 조회 3,340
19년 전 조회 1,985
19년 전 조회 2,514
19년 전 조회 2,599
19년 전 조회 2,696
19년 전 조회 2,973
19년 전 조회 2,602
19년 전 조회 3,004
19년 전 조회 2,783
19년 전 조회 3,551
19년 전 조회 1,909
19년 전 조회 2,765
19년 전 조회 2,408
19년 전 조회 2,050
19년 전 조회 2,467
19년 전 조회 1,899
19년 전 조회 5,462
19년 전 조회 2,312
19년 전 조회 4,265
19년 전 조회 2,334
19년 전 조회 1,884
19년 전 조회 2,638
19년 전 조회 2,385
19년 전 조회 2,578
19년 전 조회 2,206
19년 전 조회 3,963
19년 전 조회 3,463
19년 전 조회 2,228
19년 전 조회 2,140
19년 전 조회 2,008
19년 전 조회 2,039
19년 전 조회 4,411
19년 전 조회 3,377
19년 전 조회 2,811
19년 전 조회 3,379
19년 전 조회 3,041
19년 전 조회 2,878
19년 전 조회 2,368
19년 전 조회 2,197
19년 전 조회 2,521
19년 전 조회 3,141
19년 전 조회 2,150
19년 전 조회 3,138
19년 전 조회 3,289
19년 전 조회 2,947
19년 전 조회 1,969
19년 전 조회 1,730
19년 전 조회 2,359
19년 전 조회 2,277
19년 전 조회 1,644
19년 전 조회 1,697
19년 전 조회 1,598
19년 전 조회 2,098
19년 전 조회 1,652
19년 전 조회 2,214
19년 전 조회 1,938
19년 전 조회 1,832
19년 전 조회 1,677
19년 전 조회 1,875
19년 전 조회 1,925
19년 전 조회 1,969
19년 전 조회 2,718
19년 전 조회 5,346
19년 전 조회 1,744
19년 전 조회 1,602
19년 전 조회 1,456
19년 전 조회 1,618
19년 전 조회 1,565
19년 전 조회 1,476
19년 전 조회 1,483
19년 전 조회 1,400
19년 전 조회 1,481
19년 전 조회 2,827
19년 전 조회 3,842