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

请教关于JS对象名传递后的使用.
请教关于JS对象名传递后的使用.
javascript调用自定义函数,将对象名传过去后,怎么使用.
<input name="md_nb" type="text" size="2" maxlength="2" onClick="cls(this.name)">
<script language="javascript">
function cls(str){
  document.form1.'str'.value="";
}
 我想这一句document.form1.'str'.value="";(这个是错的.)
应该是document.form1.md_nb.value="";

------解决方案--------------------
document.form1[str][0].value="";
------解决方案--------------------
document.getElementById()