【发布时间】:2011-04-11 01:12:47
【问题描述】:
如果有人选择“其他”选项,我正在尝试用文本字段替换我的下拉菜单。现在在我的代码中,我将它替换为段落元素,因为我懒得找到用于设置文本字段的确切构造函数参数。 However, when "other" is selected nothing happens.
有人知道这是怎么回事吗?
<html>
<head>
<script type="text/javascript">
function testfunc(arg) {
if(arg.value == "other") {
document.thing.replaceChild(document.test, document.thing.selection)
}
else {
alert("stuff")
}
}
</script>
<body>
<form name="thing">
<select name="selection" onchange="testfunc(document.thing.selection.options[document.thing.selection.selectedIndex])">
<option>yes</option>
<option>no</option>
<option>other</option>
</select>
</form>
<p name="test">lkjsdf</p>
</body>
</html>
【问题讨论】:
标签: javascript javascript-events