<% 
m=1
response.write "<div id='" & m & "'></div>"
response.write "<button onclick='loadContent(" & m & ")'>答案</button>"
%>
  <script>
  function   loadContent(fff)  {   fff.innerHTML="这就是答案"   
  }   
    
  </script>本人没学过js,可是还是要用到,所以如果这个问题很弱智,也请大大么不吝赐教!为什么这个 m值无法传递到这个loadcontent函数? fff始终为空?

解决方案 »

  1.   

    <% 
    m=1 
    response.write " <div id='" & m & "'> </div>" 
    response.write " <button onclick='loadContent(""" & m & """)'>答案 </button>" 
    %> 
      <script> 
      function  loadContent(fff)   {  document.getElementById(fff).innerHTML="这就是答案"  
      }  
        
      </script> 
      

  2.   

    楼上没错
    response.write " <button onclick='loadContent(" & m & ")'>答案 </button>" 
    这句有问题吧。
      

  3.   

    1楼是对的, 参数应该是字符串类型
    通过名字找到元素, 赋值, 不过好像是用InnerText比较合适, 因为 这就是答案 不是html代码.
      

  4.   

    把m的值改成 "m1" 在看看, 按你这样写的话,fff是个数字,而不是div对象