selectbox 선택했던 그대로 유지하고 싶습니다.
<script type="text/javascript">
function ok_ttt(_year, _month){
document.getElementsByName("toYear")[0].value = $("#year1").val();
document.getElementsByName("toMonth")[0].value = _month;
//alert($('input[name="toYear"]').val());
document.ft.submit();
}
</script>
<?
if($R['year1'] && $R['month1']) {
$year1 = $R['year1'];
$month1 = $R['month1'];
} else {
$year1 = substr($date['today'],0,4);
$month1 = substr($date['today'],4,2);
}
?>
<td class="fa fa-angle-left fa-lg">
<select name="year1" id="year1">
<?php for($i=$date['year']-6;$i<$date['year']+1;$i++):?>
<option value="<?php echo $i?>"<?php if($year1==$i):?> selected="selected"<?php endif?>>
<?php echo $i?>
</option><?php endfor?>
</select>
<select name="month1" onChange="ok_ttt('<?=$_year_l?>',this.value)">
<?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>
select box 이용해서 바로 페이지 이동하게끔 했습니다.
처음 홈페이지에 들어가면 오늘날짜인 2017년 8월이 떠있어야합니다.
저 소스로 하니 오늘날짜가 자동으로 뜹니다
문제는 2016년 7월을 선택했을 때
selectbox 내의 숫자가 다시 오늘날짜인 2017년 8월로 돌아가버립니다.
현재 화면에서 새로고침되면서 결과값이 나오고 있습니다.
원하는 날짜를 선택했을때 그 날짜가 새로고침됐어도 그대로 유지되게끔 하고싶습니다.
답변 3개
$_GET['toMonth'] 값이 1월 ~ 9월일때
01, 02.. 와 같은 값이 아니라 1, 2 와 같은 값이 전달되고 있다면
if ($_GET['toYear'] && $_GET['toMonth']) { $year1 = $_GET['toYear']; $month1 = strlen($_GET['toMonth']) === 1 ? '0'.$_GET['toMonth'] : $_GET['toMonth'] ;} else { $year1 = date('Y'); $month1 = date('m');}
와 같이 소스를 변경해 보세요
답변을 작성하려면 로그인이 필요합니다.