콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,222
19년 전 조회 3,282
19년 전 조회 3,020
19년 전 조회 4,853
19년 전 조회 2,684
19년 전 조회 3,296
19년 전 조회 3,128
19년 전 조회 1,978
19년 전 조회 3,117
19년 전 조회 1,860
19년 전 조회 2,327
19년 전 조회 2,399
19년 전 조회 3,978
19년 전 조회 3,162
19년 전 조회 3,087
19년 전 조회 2,533
19년 전 조회 1,993
19년 전 조회 1,634
19년 전 조회 2,402
19년 전 조회 2,322
19년 전 조회 1,811
19년 전 조회 1,808
19년 전 조회 2,598
19년 전 조회 2,571
19년 전 조회 1,871
19년 전 조회 2,101
19년 전 조회 3,289
19년 전 조회 1,942
19년 전 조회 2,485
19년 전 조회 2,561
19년 전 조회 2,653
19년 전 조회 2,929
19년 전 조회 2,556
19년 전 조회 2,971
19년 전 조회 2,754
19년 전 조회 3,506
19년 전 조회 1,862
19년 전 조회 2,726
19년 전 조회 2,363
19년 전 조회 2,013
19년 전 조회 2,419
19년 전 조회 1,865
19년 전 조회 5,434
19년 전 조회 2,251
19년 전 조회 4,236
19년 전 조회 2,290
19년 전 조회 1,842
19년 전 조회 2,582
19년 전 조회 2,323
19년 전 조회 2,523
19년 전 조회 2,157
19년 전 조회 3,905
19년 전 조회 3,411
19년 전 조회 2,193
19년 전 조회 2,100
19년 전 조회 1,968
19년 전 조회 1,984
19년 전 조회 4,363
19년 전 조회 3,343
19년 전 조회 2,769
19년 전 조회 3,342
19년 전 조회 2,995
19년 전 조회 2,834
19년 전 조회 2,337
19년 전 조회 2,155
19년 전 조회 2,480
19년 전 조회 3,091
19년 전 조회 2,116
19년 전 조회 3,111
19년 전 조회 3,241
19년 전 조회 2,913
19년 전 조회 1,932
19년 전 조회 1,696
19년 전 조회 2,312
19년 전 조회 2,249
19년 전 조회 1,619
19년 전 조회 1,653
19년 전 조회 1,556
19년 전 조회 2,062
19년 전 조회 1,607
19년 전 조회 2,174
19년 전 조회 1,906
19년 전 조회 1,794
19년 전 조회 1,641
19년 전 조회 1,834
19년 전 조회 1,881
19년 전 조회 1,937
19년 전 조회 2,682
19년 전 조회 5,310
19년 전 조회 1,715
19년 전 조회 1,561
19년 전 조회 1,427
19년 전 조회 1,585
19년 전 조회 1,518
19년 전 조회 1,439
19년 전 조회 1,443
19년 전 조회 1,367
19년 전 조회 1,436
19년 전 조회 2,800
19년 전 조회 3,819
🐛 버그신고