셀렉트에서 날짜를 선택하면 바로 그 해당 데이터가 보이게끔 하고싶습니다.

셀렉트에서 날짜를 선택하면 바로 그 해당 데이터가 보이게끔 하고싶습니다.

QA

셀렉트에서 날짜를 선택하면 바로 그 해당 데이터가 보이게끔 하고싶습니다.

본문



기존에는 달력이 나오면서  


<script type="text/javascript">

function ok_ttt(_year, _month){

document.getElementsByName("toYear")[0].value = _year;

document.getElementsByName("toMonth")[0].value = _month;

//alert($('input[name="toYear"]').val());

document.ft.submit();

}

</script>


<?

//연도계산처리하기

$_year_l = $year;

$_month_l = $month-1;


$_year_r = $year;

$_month_r = $month+1;

if((int)$month==1){

$_year_l = (int)$year-1;

$_month_l = 12;

}else if((int)$month==12){

$_year_r = (int)$year+1;

$_month_r = 1;

}


$year1 = substr($date['today'],0,4);

$month1 = substr($date['today'],4,2);

$day1 = substr($date['today'],6,2);

$hour1 = 0;

$year2 = substr($date['today'],0,4);

$month2 = substr($date['today'],4,2);

$day2 = substr($date['today'],6,2);

$hour2 = 23;


?>


이 스크립트를 이용하여


<i class="fa fa-angle-left fa-lg" style='cursor:pointer;' title='<?=$_year_l?>년<?=$_month_l<10?"0".$_month_l:$_month_l?>월' onclick='ok_ttt("<?=$_year_l?>","<?=$_month_l<10?"0".$_month_l:$_month_l?>")'></i> 

 <span><?=$year?>년 <?=$month?>월</span> 

<i class="fa fa-angle-right fa-lg" style='cursor:pointer;' title='<?=$_year_r?>년<?=$_month_r<10?"0".$_month_r:$_month_r?>월' onclick='ok_ttt("<?=$_year_r?>","<?=$_month_r<10?"0".$_month_r:$_month_r?>")'></i>


이렇게 가운데 2017년 8월 이라는 숫자가 나오고 양옆에 < > 화살표가 나와서


마우스를 클릭하면 전월이나 다음달로 이동할 수 있게끔 해놓은 상태였습니다.


제가 하고싶은 기능은


셀렉트로 날짜를 나오게끔 하고


예를들어 2017년 5월을 클릭하면 자동으로 그해의 데이터가 나오게끔 하고 싶은데요


<td class="fa fa-angle-left fa-lg">

<select name="year1">

<?php for($i=$date['year']-2;$i<$date['year']+4;$i++):?>

<option value="<?php echo $i?>"<?php if($year1==$i):?> selected="selected"<?php endif?>>

<?php echo $i?>

</option><?php endfor?>

</select>


<select name="month1">

<?php for($i=1;$i<13;$i++):?>

<option value="<?php echo sprintf('%02d',$i)?>"<?php if($month1==$i):?> selected="selected"<?php endif?>>

<?php echo sprintf('%02d',$i)?>

</option><?php endfor?>

</select>

</td>


우선 소스는 이러한 상태이고


2015년을 먼저 선택하고 8월을 선택하면 그때 바로 그 해당 월로 넘어가서 데이터가 나오게 하고싶습니다


그게 어려우면 따로 검색버튼을 만들어서 해야하는지 그것도 궁금합니다.




이 질문에 댓글 쓰기 :

답변 1

php를 이용하여 mysql 데이터를 출력하는 것을 모르시나요?


selectbox에 onChange를 이용하면 값이 변경되었을 때 이벤트를 사용할 수 있어요


<select onChange="dataprint(this)">

</select>


<script>

function dataprint(obj){

document.location.href = "주소";

}

</script>


이 정도는 알고 있을 듯한데요


그누보드를 사용하고 있다면

<?php

$que = "select * from {$g5['member_table']}";

$res = sql_query( $que );

while( $row  = sql_fetch_array( $res )) {

echo $row['mb_id'];

}


이것이 기본적으로 php와 mysql을 연동하여 데이터를 출력하는 구문이에요.



 


답변을 작성하시기 전에 로그인 해주세요.
전체 154
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1402호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT