问一个很CAI的问题:
script js
funtion calculate()
{
document.getElementById('id').value=result;

我想把id作为一个参数,如何实现??

解决方案 »

  1.   

    funtion calculate(eId) 

    document.getElementById(eId).value=result; 
    }  
      

  2.   

    那个命名为'id'的控件代码贴出来看看另:
    document.getElementById('id ').value=result; 
    两单引号间多了个空格
      

  3.   

    function calculate(eId)  
    {  
    document.getElementById(eId).value=result;  
    } 少了一个c..复制你的代码..我晕倒..
      

  4.   

    function calculate(eId)   
    {
    var result = "value";
    document.getElementById(eId).value=result;   
    }  
      

  5.   

    在控件定义里的onclick='calculate(this);'
    在javascript里:
    funtion calculate(obj) 
    {  
    document.getElementById(obj).value=result;  
    }  
      

  6.   

    <script>
    function calculate(eId)    

    var result = "value"; 
    document.getElementById(eId).value=result;    
    }  </script>