RetroZilla/layout/html/tests/formctls/base/select_js.html

41 lines
1.1 KiB
HTML
Raw Normal View History

2015-10-21 05:03:22 +02:00
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/transitional.dtd">
<html>
<head>
<title>Adding and Removing Option Elements from a Select</title>
<script>
var isHidden = true;
var isScroll = false;
function AddContent(aDoAdd)
{
var node = document.getElementById("mySelect");
var first = null;//document.getElementById("first");
if (aDoAdd == 1) {
var notworks = false;
var option;
if (notworks) {
option = new HTMLOptionElement("Three", 3);
//option.label = "Three";
//option.value = "3";
} else {
option = new Option("Three", 3);
}
node.add(option, first);
} else {
node.remove(0);
}
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form>
This is used to test adding and removing option elements from a select as a combobox.<br><br>
<select id=mySelect size=1>
<option id="first"> Two</option>
</select>
<input type=button id="button" value="Add Content" onclick="AddContent(1)">
<input type=button id="button2" value="Remove Content" onclick="AddContent(0)">
</form>
</body>
</html>