--- In [email protected], "tamsvg" 
<[EMAIL PROTECTED]> wrote:

You can use

var text = svgdoc.createElement('text');
text.setAttribute('x',310);
text.setAttribute('y',130);
text.setAttribute('style','font-size:7pt');
text.setAttribute('id','text');
data = svgdoc.createTextNode("Data :")
text.appendChild(data);
....

or

parse string for your text element
str = "<text id='text' x='310' y='130' style='font-size:7pt'>Data : 
</text>"
text = parseXML(str , svgdoc)

Michel

> Hi!
> 
> I need to create a new text element with javascript after clicking 
on
> a circle. To create a new rect or something else is no problem, but
> how can I set the data for the new text?
> 
> This is my code:
> 
> <svg width="800" heigth="300">
> 
>   <script type="text/javascript">
>                       
>     function mouseClick(evt) {
>       var elem = evt.getTarget();
>       var svgdoc = elem.getOwnerDocument();
>       var rect = svgdoc.createElement('rect');
>       rect.setAttribute('x',300);
>       rect.setAttribute('y',100);
>       rect.setAttribute('width',200);
>       rect.setAttribute('height',150);
>       rect.setAttribute('style','stroke:grey;fill:rgb(200,200,200);
>                                  stroke-width:2');
> 
>       var text = svgdoc.createElement('text');
>       text.setAttribute('x',310);
>       text.setAttribute('y',130);
>       text.setAttribute('style','font-size:7pt');
>       text.setAttribute('id','text');
>       var child = text.getFirstChild();
>       var data = 'Data: ';
>       child.setData(data);
>                                                               
>       var parent = elem.getParentNode();
>       parent.appendChild(rect);
>       parent.appendChild(text);
>     }
> 
>   </script>
>       
>   <circle cx="20" cy="20" r="10" onclick="mouseClick(evt)" 
> style="fill:black"/>                                  
> </svg>
> 
> 
> I tried it with text.setData(data) and with child.setData(data) 
but it
> doesn't work.
> 
> Has anybody an idea?
> 
> tam





-----
To unsubscribe send a message to: [EMAIL PROTECTED]
-or-
visit http://groups.yahoo.com/group/svg-developers and click "edit my 
membership"
---- 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/svg-developers/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to