是这个的问题
document.getElementById('showarea').style.display="block";
document.getElementById('showarea').innerHTML = tmphtml;
document.getElementById('showarea').style.display="block";
document.getElementById('showarea').innerHTML = tmphtml;
解决方案 »
- ActiveXObject,里面有个"Scripting???做什么用的呢?
- 动态从取数据生成下面的表怎么实现像树一样的折叠效果
- 这里有一段WEB页面上"焦点控制"的程序,但是又实现不了,请高手帮忙看一下!!!
- 高手指点!如何实现:在同一个网页内,点小图片会在同网页中间出现大图??小图可以更新的。
- 系统时间问题
- 重返CSDN [提供个通用表单验证函数]
- 我想应该是很菜的问题吧,搞得我都不太好意思问哦
- 怎样判断文本框不能为空以及只能为数字?
- 怎么实现在textarea后加按钮,点击向textarea内添加固定文字啊,求大神
- jsp局部form表单怎么刷新
- JAVASCRIPT做网站计数器如何防刷新
- 缺少";"和缺少对象
或放到window.onload 函数里去.
<body onload="init();">
<div id="showarea" style="display:none;"> <input type="hidden" id="areavalue" value="0">
</div>
</body>
<script>
function init(){
areaname="北京 |天津 |江苏";
areaid="1 |2 |3";
areanamearr=areaname.split(" |");
areaidarr=areaid.split(" |");
tmphtml="";
tmphtml="地区: <select name='areaselect' onchange=\"javascript:document.getElementById('areavalue').value=this.value;\">";
for(i=0;i <areanamearr.length;i++)
{
tmphtml=tmphtml+" <option value='"+areaidarr[i]+"'>"+areanamearr[i]+" </option>";
}
tmphtml=tmphtml+" <select> <br>";
//alert(tmphtml);
document.getElementById('showarea').style.display="block";
document.getElementById('showarea').innerHTML = tmphtml;
}
</script>
</html>
<html>
<body onload="init();">
<div id="showarea" style="display:none;"></div>
<input type="text" id="areavalue" value="0">
</body>
</html>
<script>
function init(){
areaname="北京 |天津 |江苏";
areaid="1 |2 |3";
areanamearr=areaname.split(" |");
areaidarr=areaid.split(" |");
tmphtml="";
tmphtml="地区: <select name='areaselect' onchange=\"javascript:document.getElementById('areavalue').value=this.value;\">";
for(i=0;i <areanamearr.length;i++)
{
tmphtml=tmphtml+" <option value='"+areaidarr[i]+"'>"+areanamearr[i]+" </option>";
}
tmphtml=tmphtml+" <select> <br>";
//alert(tmphtml);
document.getElementById('showarea').style.display="block";
document.getElementById('showarea').innerHTML = tmphtml;
}
</script>
</div> 为什么会这样呢,因为你的input是被DIV成包含了
当你document.getElementById('showarea').innerHTML = tmphtml; 的时候,input标签就没有了,所有就找不到对象了