日期:2014-05-16  浏览次数:20353 次

HTML 中的JAVASCRIPT运行错误?
<html>
<head><title>DHTML技术编程</title>
<script>
function allowsend(f)
  { var echo,inp,i,s=0;
  echo=window.confirm("confirm submit?");
  inp = "name=" + f.name.value + "\n";
  inp += "age=" + f.age.value + "\n";
  for(i=0; i<f.sex.length; i++)
  { if(f.sex[i].checked)
  { inp += "sex=" + f.sex[i].value + "\n";
  s=1;}
  } 
  if(s!=1) 
  {inp += "sex=" + "null" + "\n";}
  for(i = 0;i<f.aca.length;i++)
  {if(f.aca.options[i].selected) inp+=f.aca.options[i].value+";";
  }
  for(i = 0;i<f.dep.length;i++)
  {if(f.dep.options[i].selected) inp+=f.dep.options[i].value+";";}
  inp += "submit=" + echo;
  result.innerText=inp; 
  return echo;
  } 
  function check1()
  { var pat1 = /^[a-z]{1,20}$/i;
  var str1 = name.value;
  res1.innerText = pat1.test(str1);
  }
  function check2()
  { var pat2 = /^[0-9]{1,3}$/;
  var str2 = age.value;
  res2.innerText = pat2.test(str2);
  }
</script>
</head>
<body bgcolor = "peachpuff">
<p style = "text-align:center;font-family:楷体;font-size:30">Please enter your information</p>
<form action = "javascript:void(0)" method="post" onsubmit = "return allowsend(this)" style = "font-family:楷书;font-size:20">
  Name :<input id = "name" name = "name" type = "text" />
  <input type = "button" value = "check" onclick = "check1()"/><span id = "res1">result</span></br>
  Age :<input id = "age" name = "age" type = "text"/>
  <input type = "button" value = "check" onclick = "check2()"/><span id = "res2">result</span></br>
  SEX :F:<input type="radio" id="sex" name="sex" value="F"/>
  M:<input type="radio" id="sex" name="sex" value="M"/><br/>
  ACADEMY:<select id = "aca" name = "aca" mutiple = "true">
  <option value = "计算机科学与工程">计算机科学与工程</option>
  <option value = "计算机信息系统">计算机信息系统</option>
  <option value = "通信工程">通信工程</option>
  </select></br>
  DEPARTMENT:<select id = "dep" name = "dep" mutiple = "true">
  <option value = "信息与计算科学">信息与计算科学</option>
  <option value = "计算机科学与技术">计算机科学与技术</option>
  <option value = "软件工程">软件工程</option>
  </select></br>
  <input type="submit" value=" 提交"/>
  <input type = "reset" value = "重置"/>
<div id="result" style="border-style:inset">display your input</div>
  <a href="index.html"> 返回首页 &l