|
|
|
| Задача динамически сгенерировать чекбокс с текстом, полученым из select.
Вот собственно код:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>test</title>
<script type="text/javascript">
function showSelected(a)
{
var selNum = a.object_type.selectedIndex;
var selText = a.object_type.options[selNum].text;
var input = document.createElement("INPUT");
input.setAtribute("type","checkbox");
input.setAtribute("name","test");
input.appendChild(selText);
document.getElementsByTagName("FORM")[0].appendChild(input);
}
</script>
</head>
<body>
<form action="test.php" method="post">
<select name="object_type" id="object_type_variant" onChange="showSelected(this.form)">
<option id="first">Layot</option>
<option>Article</option>
<option>Picture</option>
</select>
</form>
</body>
</html>
|
| |
|
|
|
|
|
|
|
для: diez
(02.10.2007 в 11:56)
| |
function showSelected(a)
{
var input = document.createElement("input");
input.setAtribute("type", "checkbox");
input.setAtribute("name", "test");
var text = document.createTextNode(a.object_type.value);
a.appendChild(input);
a.appendChild(text);
}
|
| |
|
|
|