Jsp - 버튼제어3

2020. 6. 16. 11:32Jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
 
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
//window(창) - location(주소줄)
//- history(방문기록)
//- document(html문서) ->image,link,layer...
//                                            - form(로그인창)->text,password,textarea
//                                            -checkbox, radio
//                                            -select - option
//window.document.폼이름.목록상자이름.변수 ->type ,name, length, 
//                                                                         selectedIndex->선택된 항목의 번호저장, options[]
 
// window.document.폼이름.목록상자이름.options[0].변수  text  value;
//                                                                    selected ->항목이 선택되면 true, 안되있으면 false
//window.document.폼이름.목록상자이름.함수() -> focus() ,blur()
 
function fun1() {
    alert(document.fr.sel.type);
    alert(document.fr.sel.name);
    alert(document.fr.sel.length);
    alert(document.fr.sel.selectedIndex);
}
function fun2() {
    alert(document.fr.sel.options[0].text);
    alert(document.fr.sel.options[0].value);
    alert(document.fr.sel.options[0].selected);//선택되면 true,아니면 false
    document.fr.sel.focus();
}
function fun3() {
    if(document.fr.sel.options[0].selected==true){
        alert("목록상자 선택하세요");
        document.fr.sel.focus();
        return;
    }
}
</script>
</head>
<body>
<h1>js3/test5.html</h1>
<form action="a.jsp" method="get" name="fr">
목록상자 :<select name="sel">
<option value="">선택하세요</option>
<option value="sel1">선택1</option>
<option value="sel2">선택2</option>
<option value="sel3">선택3</option>
</select><br>
 
<input type="button" value="버튼" onclick="fun1()">
<input type="button" value="항목정보" onclick="fun2()">
<input type="button" value="목록제어" onclick="fun3()">
</form>
</body>
</html>
cs

 

 

 

'Jsp' 카테고리의 다른 글

Jsp - 회원가입전송  (0) 2020.06.17
Jsp - 회원가입창  (0) 2020.06.16
Jsp - 버튼제어2  (0) 2020.06.16
Jsp - 버튼제어  (0) 2020.06.16
Jsp - input ,type  (0) 2020.06.16