以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 SVG/GML/VRML/X3D/XAML 』  (http://bbs.xml.org.cn/list.asp?boardid=21)
----  比较头疼SVG和后台的交互...大家帮我看看下面的代码  (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=33824)


--  作者:孤剑飘零
--  发布时间:6/5/2006 10:59:00 AM

--  比较头疼SVG和后台的交互...大家帮我看看下面的代码
for (var i=0;i< gtXPointArr.length ; i++)
 {
  rectobj=svgdoc.createElementNS(svgns,"text");
  rectobj.setAttribute("x",parseFloat( gtXPointArr[i] ) );
  rectobj.setAttribute("y",parseFloat( gtYPointArr[i] ) );
  rectobj.setAttribute("onmousemove","ShowTip(evt,'"+ gtName[i] + "','" + gtBH[i] + "','" + gtSM[i] + "')");
  rectobj.setAttribute("onclick","HideTip()");
  rectobj.setAttribute("id","text" + i); 
  svgroot.appendChild(rectobj);
                 var textobj = svgdoc.getElementById("text" + i);
  textobj.getFirstChild().nodevalue="newvalue";
}

我是要根据gtXPointArr数组中的值在SVG中动态创建text对象.但是<text>abc</text>中的abc怎么出来啊..怎么赋值的???求救中


--  作者:DragonJohn
--  发布时间:6/5/2006 11:11:00 AM

--  
var CityText=svgDoc.createElement('text');
    CityText.setAttribute('x',DLBx[i]);
    CityText.setAttribute('y',DLBy[i]);
    CityText.setAttribute('class','EnMarkText');
    CityText.appendChild(svgDoc.createTextNode(DLBtext[i]));
    svgDoc.getElementById("EnNodeText").appendChild(CityText);
--  作者:wangjianredfox
--  发布时间:6/5/2006 12:24:00 PM

--  
好东西啊,学习!!
--  作者:方竹
--  发布时间:6/5/2006 1:49:00 PM

--  
帮忙顶啊!
--  作者:bluehxjing
--  发布时间:6/5/2006 3:29:00 PM

--  
能给发个完整的SVG与后台交互例子嘛?谢谢!
--  作者:tamefox
--  发布时间:6/5/2006 4:26:00 PM

--  
你可以给那个text元素定义一个id
<text id="aa">aaa</text>
var textobj = svgdoc.getElementById("aaa");
textobj.firstChild.nodeValue=你设置的变量;

注意字母的大小写!



W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.997ms