-
select box option text와 value 활용프로그래밍/자바 2018. 8. 27. 11:11
jsp페이지에서 보이는 text값이나
<option value>에 넣어둔 안보이는 value값을 활용할 수 있다.
<select id="a">
<option value="b">content</option>
<option value="b2">content2</option>
</select>
<script>
var selectdata = document.getElementById("a");
var text1 = selectdata.options[selectdata.selectIndex].text);
var value1= selectdata.options[selectdata.selectIndex].value);
</script>
첫번째 select를 눌렀을 경우 데이터는
text1은 content를 갖고
value1은 b를 갖는다.'프로그래밍 > 자바' 카테고리의 다른 글
스크립트 로그인 쿠키 (0) 2018.08.27 jsp에서 넘기는 파라미터가 한글일 때 서블릿에서 깨지는 경우 (0) 2018.08.27 svn checkout Maven 라이브러리 오류 해결방법 (0) 2018.08.27 이클립스 프로젝트명 변경시 해야할 것 (0) 2018.08.27 JSP에서 페이징 번호 붙이기 (egov Pagination 사용) (0) 2018.03.02