콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,236
19년 전 조회 3,298
19년 전 조회 3,038
19년 전 조회 4,872
19년 전 조회 2,701
19년 전 조회 3,312
19년 전 조회 3,149
19년 전 조회 1,996
19년 전 조회 3,133
19년 전 조회 1,877
19년 전 조회 2,341
19년 전 조회 2,416
19년 전 조회 3,995
19년 전 조회 3,182
19년 전 조회 3,109
19년 전 조회 2,546
19년 전 조회 2,011
19년 전 조회 1,651
19년 전 조회 2,424
19년 전 조회 2,340
19년 전 조회 1,828
19년 전 조회 1,825
19년 전 조회 2,615
19년 전 조회 2,586
19년 전 조회 1,890
19년 전 조회 2,121
19년 전 조회 3,306
19년 전 조회 1,958
19년 전 조회 2,501
19년 전 조회 2,577
19년 전 조회 2,673
19년 전 조회 2,948
19년 전 조회 2,571
19년 전 조회 2,988
19년 전 조회 2,769
19년 전 조회 3,523
19년 전 조회 1,883
19년 전 조회 2,741
19년 전 조회 2,379
19년 전 조회 2,029
19년 전 조회 2,432
19년 전 조회 1,887
19년 전 조회 5,449
19년 전 조회 2,273
19년 전 조회 4,253
19년 전 조회 2,308
19년 전 조회 1,859
19년 전 조회 2,600
19년 전 조회 2,342
19년 전 조회 2,538
19년 전 조회 2,178
19년 전 조회 3,923
19년 전 조회 3,423
19년 전 조회 2,206
19년 전 조회 2,116
19년 전 조회 1,985
19년 전 조회 2,005
19년 전 조회 4,385
19년 전 조회 3,358
19년 전 조회 2,781
19년 전 조회 3,362
19년 전 조회 3,007
19년 전 조회 2,850
19년 전 조회 2,350
19년 전 조회 2,171
19년 전 조회 2,502
19년 전 조회 3,107
19년 전 조회 2,133
19년 전 조회 3,125
19년 전 조회 3,256
19년 전 조회 2,928
19년 전 조회 1,948
19년 전 조회 1,712
19년 전 조회 2,328
19년 전 조회 2,261
19년 전 조회 1,633
19년 전 조회 1,666
19년 전 조회 1,568
19년 전 조회 2,082
19년 전 조회 1,632
19년 전 조회 2,189
19년 전 조회 1,919
19년 전 조회 1,817
19년 전 조회 1,658
19년 전 조회 1,846
19년 전 조회 1,898
19년 전 조회 1,953
19년 전 조회 2,701
19년 전 조회 5,323
19년 전 조회 1,730
19년 전 조회 1,579
19년 전 조회 1,441
19년 전 조회 1,602
19년 전 조회 1,534
19년 전 조회 1,454
19년 전 조회 1,465
19년 전 조회 1,385
19년 전 조회 1,450
19년 전 조회 2,813
19년 전 조회 3,832