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 와 같은 값이 전달되고 있다면
</span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">if ($_GET['toYear'] && $_GET['toMonth']) {</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"> $year1 = $_GET['toYear'];</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"> $month1 = strlen($_GET['toMonth']) === 1 ? '0'.<span style="font-size: 14.004px;">$_GET['toMonth'] : </span><span style="font-size: 14.004px;">$_GET['toMonth']</span><span style="font-size: 14.004px;"> ;</span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">} else {</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="font-size: 11pt;"> $year1 = date('Y');</span></p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"> $month1 = date('m');</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;">}</p><p style="word-break: break-all; color: rgb(80, 80, 80); font-family: Arial, 돋움, Dotum; font-size: 14.004px;"><span style="font-size: 14.004px;">
와 같이 소스를 변경해 보세요
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인