一javascript下代码:
function addurl() {
 txt2=prompt("链接文本显示.\n如果不想使用, 可以为空, 将只显示超级链接地址. ",""); 
    if (txt2!=null) 
      {
txt=prompt("超级链接.","http://");      
if (txt!="http://" && txt!=null) {
if (txt2=="") 
             {
AddTxt=""+txt+"";
AddText(AddTxt);
    } 
             else {
AddTxt=""+txt2+"";
AddText(AddTxt);
}         
    }    
}
}----------------上面调用下面的函数-----------
function AddText(NewCode) {
document.theForm.text.value+=NewCode;
document.theForm.text.focus();
}
theForm为表单名,method="post" runat="server"  text为文本域的name(TextBox TextMode="MultiLine")-------------------------------
我现在要加一文本链接,调用上面的addurl后,没能么回值,写到text里面,
提示“document.theForm.text为空域不是对像”
但把text换成,客户端控件(input)就不会出错怎么回事呀,谢谢

解决方案 »

  1.   

    tryfunction AddText(NewCode) {
    document.getElementsByName('text')[0].value+=NewCode;
    document.getElementsByName('text')[0].focus();
    }
      

  2.   

    var obj=document.getElementById("TextBox1");
      

  3.   

    谢谢
     vivianfdlpw()  and renyu732(Sysinfo)
    为什么用这个呢???
    最终服务器控件不是都转成HTML控件了吗?
      

  4.   

    是因为生成后,服务端控件的name不是原来那个,是服务端控件自己生成的。
      

  5.   

    服务器端生成HTML控件
    后会自动生成和ID号一样的name的