콤보박스 출력용 함수

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

//콤보 박스를 생성한다. 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,234
19년 전 조회 3,295
19년 전 조회 3,035
19년 전 조회 4,868
19년 전 조회 2,697
19년 전 조회 3,311
19년 전 조회 3,141
19년 전 조회 1,991
19년 전 조회 3,129
19년 전 조회 1,873
19년 전 조회 2,339
19년 전 조회 2,413
19년 전 조회 3,989
19년 전 조회 3,177
19년 전 조회 3,105
19년 전 조회 2,542
19년 전 조회 2,004
19년 전 조회 1,647
19년 전 조회 2,417
19년 전 조회 2,337
19년 전 조회 1,827
19년 전 조회 1,822
19년 전 조회 2,612
19년 전 조회 2,583
19년 전 조회 1,886
19년 전 조회 2,117
19년 전 조회 3,302
19년 전 조회 1,957
19년 전 조회 2,497
19년 전 조회 2,574
19년 전 조회 2,667
19년 전 조회 2,945
19년 전 조회 2,569
19년 전 조회 2,982
19년 전 조회 2,768
19년 전 조회 3,518
19년 전 조회 1,877
19년 전 조회 2,737
19년 전 조회 2,376
19년 전 조회 2,026
19년 전 조회 2,431
19년 전 조회 1,880
19년 전 조회 5,445
19년 전 조회 2,268
19년 전 조회 4,250
19년 전 조회 2,305
19년 전 조회 1,854
19년 전 조회 2,597
19년 전 조회 2,337
19년 전 조회 2,534
19년 전 조회 2,177
19년 전 조회 3,919
19년 전 조회 3,422
19년 전 조회 2,204
19년 전 조회 2,113
19년 전 조회 1,982
19년 전 조회 2,000
19년 전 조회 4,383
19년 전 조회 3,358
19년 전 조회 2,780
19년 전 조회 3,360
19년 전 조회 3,006
19년 전 조회 2,846
19년 전 조회 2,347
19년 전 조회 2,169
19년 전 조회 2,497
19년 전 조회 3,104
19년 전 조회 2,130
19년 전 조회 3,123
19년 전 조회 3,255
19년 전 조회 2,926
19년 전 조회 1,946
19년 전 조회 1,709
19년 전 조회 2,325
19년 전 조회 2,260
19년 전 조회 1,632
19년 전 조회 1,664
19년 전 조회 1,566
19년 전 조회 2,080
19년 전 조회 1,629
19년 전 조회 2,186
19년 전 조회 1,917
19년 전 조회 1,813
19년 전 조회 1,656
19년 전 조회 1,845
19년 전 조회 1,897
19년 전 조회 1,948
19년 전 조회 2,698
19년 전 조회 5,321
19년 전 조회 1,727
19년 전 조회 1,576
19년 전 조회 1,440
19년 전 조회 1,599
19년 전 조회 1,532
19년 전 조회 1,452
19년 전 조회 1,460
19년 전 조회 1,383
19년 전 조회 1,448
19년 전 조회 2,813
19년 전 조회 3,831