자기 혐오 개발자
html 라디오 버튼 제어 본문
jQuery 단.
$(document).ready(function(){
$('input[type=radio][name=이름]').change(function(){
// 함수 호출.
fn_radio_call();
});
});
// 함수...
function fn_radio_call(){
var test_val = $(":input:radio[name=이름]:checked").val();
$.ajax({
type: "POST",
url: "${pageContext.request.contextPath}/testService",
data: {"test_val":test_val},
dataType: 'json',
success: function (data) {
if (data.result > 0) {
location.reload();
}
else {
alert("에러가 발생했습니다.\n잠시후 다시 시도해 주세요.");
}
},
error: function (e) {
alert("에러가 발생했습니다.\n잠시후 다시 시도해 주세요.");
}
});
}
HTML 단.
<td>
<span><input type="radio" name="이름" id="radio_이름_1" value="Y" <c:if test="${vo.test_val == 'Y'}">checked</c:if>>Yes</span>
<span><input type="radio" name="이름" id="radio_이름_2" value="N" <c:if test="${vo.test_val == 'N'}">checked</c:if>>No</span>
</td>
Java 단.
@RequestMapping(value = "/testService", method = RequestMethod.POST)
public String test(HttpSession session,
@RequestParam(value = "test_val", defaultValue = "") String testVal, Model model) {
try {
} catch (Exception e) {
}
return "jsonView";
}
'Javascript,jQuery' 카테고리의 다른 글
img 태그 안에 default 이미지 설정하는 방법. (0) | 2018.06.20 |
---|---|
toggle이 열렸는가 안열렸는가 감지하는 방법. (0) | 2018.06.04 |
[jQuery] 드래그해서 정렬, 순서조정 (0) | 2018.05.28 |
INPUT 박스에서 숫자만 입력 되도록 설정 (0) | 2016.10.31 |
Session이 끊겼을때, 팝업을 띄우니 로그인창이 나오면.. (0) | 2016.10.31 |