summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/select/select-replace-option.html
blob: 3eac99694d16d170729fdf0cf903e433ebc2ad34 (plain)
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
<head>
<script>
function test()
{
    if (window.testRunner)
        testRunner.dumpAsText();
    var select = document.getElementById('select');
    select.options[1] = new Option("Replacement Option 1", "Replacement Option 1");
    var length = select.options.length;
    for (var i = 0; i < length; ++i) {
        var message = "options[" + i + "] is " + select.options[i].innerHTML;
        var paragraph = document.createElement('div');
        paragraph.appendChild(document.createTextNode(message));
        document.getElementById('console').appendChild(paragraph);
    }
    var message = "selected index is " + select.selectedIndex;
    var paragraph = document.createElement('p');
    paragraph.appendChild(document.createTextNode(message));
    document.getElementById('console').appendChild(paragraph);
}
</script>
</head>
<body onload="test();">
<p>This tests replacing an option using JavaScript. If successful, the options should be "Replacement Option 0", "Option 1", and "Option 2", and selected index should be 0.<form>
<form>
<select id="select">
<option>Option 0</option>
<option>Option 1</option>
<option>Option 2</option>
</select>
</form>
<p id="console"></p>
</body>