콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,221
19년 전 조회 3,280
19년 전 조회 3,017
19년 전 조회 4,852
19년 전 조회 2,680
19년 전 조회 3,294
19년 전 조회 3,125
19년 전 조회 1,974
19년 전 조회 3,115
19년 전 조회 1,857
19년 전 조회 2,324
19년 전 조회 2,395
19년 전 조회 3,975
19년 전 조회 3,160
19년 전 조회 3,085
19년 전 조회 2,529
19년 전 조회 1,993
19년 전 조회 1,633
19년 전 조회 2,400
19년 전 조회 2,320
19년 전 조회 1,809
19년 전 조회 1,805
19년 전 조회 2,595
19년 전 조회 2,569
19년 전 조회 1,868
19년 전 조회 2,100
19년 전 조회 3,284
19년 전 조회 1,939
19년 전 조회 2,481
19년 전 조회 2,556
19년 전 조회 2,651
19년 전 조회 2,927
19년 전 조회 2,554
19년 전 조회 2,968
19년 전 조회 2,751
19년 전 조회 3,504
19년 전 조회 1,860
19년 전 조회 2,723
19년 전 조회 2,360
19년 전 조회 2,010
19년 전 조회 2,417
19년 전 조회 1,861
19년 전 조회 5,430
19년 전 조회 2,248
19년 전 조회 4,233
19년 전 조회 2,288
19년 전 조회 1,839
19년 전 조회 2,580
19년 전 조회 2,320
19년 전 조회 2,521
19년 전 조회 2,154
19년 전 조회 3,903
19년 전 조회 3,408
19년 전 조회 2,189
19년 전 조회 2,098
19년 전 조회 1,964
19년 전 조회 1,981
19년 전 조회 4,361
19년 전 조회 3,341
19년 전 조회 2,766
19년 전 조회 3,337
19년 전 조회 2,991
19년 전 조회 2,831
19년 전 조회 2,333
19년 전 조회 2,152
19년 전 조회 2,477
19년 전 조회 3,088
19년 전 조회 2,113
19년 전 조회 3,107
19년 전 조회 3,239
19년 전 조회 2,910
19년 전 조회 1,929
19년 전 조회 1,693
19년 전 조회 2,309
19년 전 조회 2,245
19년 전 조회 1,617
19년 전 조회 1,650
19년 전 조회 1,553
19년 전 조회 2,060
19년 전 조회 1,606
19년 전 조회 2,171
19년 전 조회 1,903
19년 전 조회 1,791
19년 전 조회 1,639
19년 전 조회 1,832
19년 전 조회 1,878
19년 전 조회 1,934
19년 전 조회 2,681
19년 전 조회 5,307
19년 전 조회 1,712
19년 전 조회 1,558
19년 전 조회 1,424
19년 전 조회 1,582
19년 전 조회 1,516
19년 전 조회 1,436
19년 전 조회 1,441
19년 전 조회 1,364
19년 전 조회 1,433
19년 전 조회 2,796
19년 전 조회 3,814
🐛 버그신고