猿问

单机提交之后显示结果,求大神帮我看一下函数部分哪里错了?

<title>无标题文档</title>
<script type="text/javascript">
function showResult()
{//显示提交结果
var 
msg = get(p1());
alert(msg);
}

function p1()
{
var ps,i;
ps=document.all.tags(getHtml(likes));
document.writeln("本文档含有"+ps.length+"个"+x+"标签对");
if(ps.length>0);
for(i=1;i<=ps.length;i++)
document.writeln("第"+i+"标签对之间的内容为:"+ps[i-1].innerText);
}

function getHtml(likes)
{//获取爱好
var i,result="";
for(i=0;i<likes.length;i++)
{
if(likes.options[i].selected) result = likes.options[i].text;
}
return result;
}

</script>

</head>
<body>
<p>tags Method retrieves a collection of <a href="../综合题(1).html">objects</a> that have the specified HTML tag name. </p>
<p>collElements = object.tags(sTag)</p>
<p>sTag specifies an <a href="../综合题(3).html">HTML</a> tag. It can be any one of the objects exposed by the DHTML Object Model. </p>
<form name="get">
<p> 
请输入所要查询的HTML标签:
<select name="likes" size="1" multiple="multiple" >
<option value="1">P</option>
<option value="2">A</option>
<option value="3">H</option>

</select>
<input type="submit" name="Button1" value="提交" onclick="showResult()" /></p>
</form>
</body>
</html>

犯罪嫌疑人X
浏览 146回答 1
1回答

慕的地6264312

各种错啊亲最大的错误是,你的button不应该是submit类型的每次点击都等于刷新界面啊如果你真想实现url中带参数那应该在页面最后再执行你的showResult方法,不然dom还没加载完,怎么可能有元素
随时随地看视频慕课网APP
我要回答