JQUERY SELECT에서 선택하자 마자 바로 액션발생시 처리하는 루틴

Posted by HULIA(휴리아)
2017. 11. 5. 07:29 프론트엔드/그래픽디자인_퍼블리싱

=============================JS=========================
$(document).ready(function(){
$('#page_limit').val('<?php echo $page_limit; ?>');
$('#search_text').val('<?php echo $search_text; ?>');
$('#search_type2').val('<?php echo $search_type2; ?>');
$("#page_limit").change(function(){
$("form[name=page_form] input[name=page_limit]").val($(this).val());
//alert($("form[name=page_form] input[name=page_limit]").val());
gopage('0');
});
$("#search_type2").change(function(){
$("form[name=page_form] input[name=search_type2]").val($(this).val());
//alert($("form[name=page_form] input[name=page_limit]").val());
gopage('0');
});
});

function gopage(page_idx){
//alert(page_idx);
document.page_form.page.value=page_idx;
document.page_form.submit();
}





=============================HTML=========================
<form name="page_form" method="POST">
<input type='hidden' name="search_text" value="<?=$search_text?>"> 
<input type='hidden' name="search_type2" value="<?=$search_type2?>"> 
<input type='hidden' name="page_limit" value="<?=$page_limit?>"> 
<input type='hidden' name="page" value="<?=$page?>">
</form>

<td bgcolor="#FFFFFF" class="in_th th_color">한페이지당목록수</td>
<td>
<select id='page_limit' name='page_limit' style='width: 80px'>
<option value='10' selected>10</option>
<option value='30'>30</option>
<option value='50'>50</option>
       </select>
</td>
<td class="in_th th_color">담보비율</td>
<td>
<select name='search_type2' id='search_type2' style='width: 120px'>
<option value='1' selected>전체</option>
<option value='2'>130%이상</option>
<option value='3'>130%이하</option>
      </select>
</td>