要实现的功能是点击图片后test的代码换成登陆代码代码如下请各位大大帮忙!
谢谢<html>
<head>
<title>无标题文档</title>
<script type="text/javascript">function loadLogin() {            document.getElementById("test").innerHTML = "<form><p>用户名<input name="textfield" type="text" id="textfield" size="10" maxlength="12" /><br />密&nbsp;&nbsp;&nbsp;&nbsp;码<input name="textfield2" type="text" id="textfield2" size="10" maxlength="12" /><br /><input type="submit" name="button" id="button" value="登陆" /><input type="reset" name="button2" id="button2" value="重置" /></p></form>";}</script>
</head><body><table width="200" border="1" cellspacing="1" cellpadding="1">
  <tr>
    <td id="test"><img src="http://www.csdn.net/Images/logo_csdn.gif" width="150" height="60" onClick="loadLogin();"/></td>
  </tr>
</table>
</body>
</html>

解决方案 »

  1.   

    建议把form放外边;你写的不可以吗?
      

  2.   


    function   loadLogin()  ===》function   loadLogin(obj)document.getElementById("test").innerHTML ===》objonClick="loadLogin();" ===》 onClick="loadLogin(this)"
      

  3.   

    this:
    fundocument.getElementById("test").innerHTML   ===》obj.innerHTML 
      

  4.   

    document.getElementById("test").innerHTML   ===》obj这个不懂什么意思呀??
      

  5.   

    <html>
    <head>
    <title>无标题文档</title>
    <script type="text/javascript">function loadLogin(obj) {            obj.innerHTML = "<p>用户名<input name="textfield" type="text" id="textfield" size="10" maxlength="12" /><br />密&nbsp;&nbsp;&nbsp;&nbsp;码<input name="textfield2" type="text" id="textfield2" size="10" maxlength="12" /><br /><input type="submit" name="button" id="button" value="登陆" /><input type="reset" name="button2" id="button2" value="重置" /></p>";}</script>
    </head><body><table width="200" border="1" cellspacing="1" cellpadding="1">
      <tr>
        <td id="test"><img src="http://www.csdn.net/Images/logo_csdn.gif" width="150" height="60" onClick="loadLogin(this);"/></td>
      </tr>
    </table>
    </body>
    </html>
    还是不行
      

  6.   

    <html> 
    <head> 
    <title> 无标题文档 </title> 
    <script type="text/javascript"> function loadLogin(obj) { 
    obj.innerHTML = '<p> 用户名 <input name="textfield" type="text" '
      +'id="textfield" size="10" maxlength="12" /> <br />'
      +'密&nbsp;&nbsp;&nbsp;&nbsp;码 <input name="textfield2"'
    +' type="text" id="textfield2" size="10" maxlength="12" /> '
    +'<br /> <input type="submit" name="button" id="button" '
    +'value="登陆" /> <input type="reset" name="button2" id="button2" value="重置" /> </p>';
    } </script> 
    </head> <body> <table width="200" border="1" cellspacing="1" cellpadding="1"> 
      <tr> 
        <td id="test"> <img src="http://www.csdn.net/Images/logo_csdn.gif" width="150" height="60" onClick="loadLogin (this.parentNode);"/><!--this.parentNode取到td行--> </td> 
      </tr> 
    </table> 
    </body> 
    </html> 
      

  7.   

    <html> 
    <head> 
    <title> 无标题文档 </title> 
    <script type="text/javascript"> function loadLogin(obj) { 
    obj.innerHTML = '<p> 用户名 <input name="textfield" type="text" '
      +'id="textfield" size="10" maxlength="12" /> <br />'
      +'密&nbsp;&nbsp;&nbsp;&nbsp;码 <input name="textfield2"'
    +' type="text" id="textfield2" size="10" maxlength="12" /> '
    +'<br /> <input type="submit" name="button" id="button" '
    +'value="登陆" /> <input type="reset" name="button2" id="button2" value="重置" /> </p>';
    } </script> 
    </head> <body> <table width="200" border="1" cellspacing="1" cellpadding="1"> 
      <tr> 
        <td id="test"> <img src="http://www.csdn.net/Images/logo_csdn.gif" width="150" height="60" onClick="loadLogin (this.parentNode);"/><!--this.parentNode取到td行--> </td> 
      </tr> 
    </table> 
    </body> 
    </html>