var t='xx';form1.t.value='值为:';我想取得t的名字为xx?即是form1.t.value===form1.xx.value

解决方案 »

  1.   

    不太明白你的意思,<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
     </HEAD> <BODY>
      <form id="form1">
      <input type="text" id="t"  value="" width="100">
      </form>
      <script>
      var t='xx'; 
      form1.t.value='值为:'; 
      if(form1.t.value==t) alert("value = xx"); 
      else alert("value != xx");
      </script>
     </BODY>
    </HTML>
      

  2.   

    不太明白你的意思,<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
     <HEAD>
      <TITLE> New Document </TITLE>
     </HEAD> <BODY>
      <form id="form1">
      <input type="text" id="t"  value="" width="100">
      </form>
      <script>
      var t='xx'; 
      form1.t.value='值为:'; 
      if(form1.t.value==t) alert("value = xx"); 
      else alert("value != xx");
      </script>
     </BODY>
    </HTML>
      

  3.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <title>无标题文档</title>
    <script language="JavaScript">
    window.onload=function(){
    var t="tt";
    alert(form1[t].value);
    }
    </script>
        </head>
        <body>
         <form name="form1">
         <input type="text" name="tt" value="hello!">
         </form>
     
        </body>
    </html>
      

  4.   

    这样也行
    form1.elements[t].value;
      

  5.   

    使用集合就可以了
    <input type="text" id="google" value="sdf"/>
    <script defer>
    var cc="google"
    alert(document.getElementById(cc).value);
    </script>