jsp select 콤보박스에 파라미터/어트리뷰트값 대입하기
|
콤보박스가 아닌, 라디오 버튼 등은 체크드
<p> <label for=”usersex”>성별</label> <input type=radio name=”sex” value=”남자” ${vo.sex==’남자’?”checked”:””}>남자 <input type=radio name=”sex” value=”여자” ${vo.sex==’여자’?”checked”:””}>여자 </p>
|
|
콤보박스는 셀렉티드
<select id=”userPhone” name=”tel1″> <option ${vo.sex==’02’?”selected”:””}>02</option> <option ${vo.sex==’031′?”selected”:””}>031</option> <option ${vo.sex==’032′?”selected”:””}>032</option> <option ${vo.sex==’051′?”selected”:””}>051</option> <option ${vo.sex==’053′?”selected”:””}>053</option> </select>
|
노가다.
|
<%@ page language=”java” contentType=”text/html; charset=EUC-KR” pageEncoding=”EUC-KR”%> <% String aaa=”동물”;//getParameter나 getAttribute로 원하는 값을 가져온다 %> <!DOCTYPE html> <html> <head> <meta http-equiv=”Content-Type” content=”text/html; charset=EUC-KR”> <title>Insert title here</title> <script> window.onload=function(){ document.getElementById(“combo”).value=document.getElementById(“ptxt”).value;
//자바스크립트로 ptxt를 찾아서 combo박스 값에 대입한다.
} </script> </head> <body> <input type=”hidden” id=”ptxt” value=<%=aaa%>> //ptxt에 aaa값(동물)을 담는다. <select id=”combo”> <option>남자</option> <option>여자</option> <option>동물</option> <option>무생물</option> </select> </body> </html>
|