336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

안녕하세요.

 

selectbox에 있는 값을 가져오거나 선택한 것을 가져오는 소스코드입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<script>
    window.onload = function(){
 
        //차례대로 
        //선택한순서
        //옵션(select박스 안쪽에 있는 값을 가져오기 위함입니다.
        //값을 가져옵니다.
        var x = document.getElementById("mySelect").selectedIndex;
        var y = document.getElementById("mySelect").options;
        var z = document.getElementById("mySelect").value;
 
        //순서대로 값을 띄워줍니다.
        alert("Index: " + y[x].index + " is " + y[x].text+" is " + z);
 
    }
</script>
<select id="mySelect">
    <option value="Banana1!">Banana</option>
    <option value="값">값 선택</option>
 
</select>
 
cs

 

감사합니다.

+ Recent posts