Hi
Yes, this was a very simple example.
You could change the ShowData function to something like that:
function ShowData(evt)
{
//set visible the text element
document.getElementById('MyText').setAttribute
('visibility','visible')
//get the name of the rect
var rectName=evt.target.getAttribute('id')
select what will be the data of the text element
var textData
switch (rectName)
{
case "rect1" :
{
textData="first rect";
break;
}
case "rect2" :
{
textData="second rect";
break;
}
case "rect3" :
{
textData="third rect";
break;
}
}
//set the data of the text
document.getElementById('MyText').firstChild.data=textData
}
For that, you have to set 'id' attribute for any rect. In my case, I
named them rect1 to rect3, but you can change their name, of course.
Jerome
--- In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote:
>
> Hi jerome,
> i try to do that you suggest me.It's work but i've one problem.
> if i've more than one rect and i want to show text on each rect,
> how i can do it.
> thanks in advance
> ?xml version="1.0" encoding="utf-8"?>
> <svg width="400px" height="400px" viewbox="0 0 400 400"
> xmlns:xlink="http://www.w3.org/1999/xlink">
> <rect x="54" y="266" width="37" height="94" fill="Red"
stroke="black"
> stroke-width="1" class="" onmouseover="ShowData(evt)"
> onmouseout="HideData(evt)" />
> <rect x="194" y="173" width="37" height="187" fill="Red"
stroke="black"
> stroke-width="1" class="" onmouseover="ShowData(evt)"
> onmouseout="HideData(evt)"/>
> <rect x="91" y="220" width="37" height="140" fill="Blue"
stroke="black"
> stroke-width="1" class="" onmouseover="ShowData(evt)"
> onmouseout="HideData(evt)"/>
>
> <text id="MyText" x="54" y="260" visibility="hidden">Hello
> World</text>
>
> <script type="text/javascript">
> <![CDATA[
>
> function ShowData(evt)
> {
> document.getElementById('MyText').setAttribute
> ('visibility','visible')
> }
>
> function HideData(evt)
> {
> document.getElementById('MyText').setAttribute
> ('visibility','hidden')
> }
> //]]>
> </script>
> </svg>
>
>
>
> "Jerome de
la
> Goutte" To: svg-
[EMAIL PROTECTED]
> <[EMAIL PROTECTED]
cc:
> ue.fr> Subject: [svg-
developers] Re: Show Data when
mouseover
>
> 09/14/2004
02:45
>
PM
> Please respond
to
> svg-
developers
>
>
>
>
>
>
> Hi
>
> for example, you can have the following SVG:
> <svg>
> <rect x="54" y="266" width="37" height="94" fill="Red"
> stroke="black" stroke-width="1" class="" onmouseover="ShowData(evt)"
> onmouseout="HideData(evt)">
> <set attributeName="fill" to="blue" begin="mouseover"
> end="mouseout"/>
> </rect>
> <text id="MyText" x="10" y="10" visibility="hidden">Hello
> World</text>
> <script><![CDATA[
> function ShowData(evt)
> {
> document.getElementById('MyText').setAttribute
> ('visibility','visible')
> }
>
> function ShowData(evt)
> {
> document.getElementById('MyText').setAttribute
> ('visibility','hidden')
> }
>
> ]]></script>
> </svg>
>
>
> This is an example, of course
>
> J�r�me
>
>
> --- In [EMAIL PROTECTED], [EMAIL PROTECTED] wrote:
> >
> > Hi jerome,
> > Could you have example for function ShowData(evt),HideData
(evt)?
> >
> thank you
> > so much
> >
> >
> >
> >
>
> > "Jerome de
> la
>
> > Goutte" To: svg-
> [EMAIL PROTECTED]
>
> > <[EMAIL PROTECTED]
> cc:
>
> > ue.fr> Subject: [svg-
> developers] Re: Show Data when
> mouseover
> >
>
> > 09/14/2004
> 02:11
>
> >
> PM
>
> > Please respond
> to
>
> > svg-
> developers
>
> >
>
> >
>
> >
> >
> >
> >
> > Hi
> >
> > In your case, I would use onmourover and onmouseout attributes :
> > <rect x="54" y="266" width="37" height="94" fill="Red"
> stroke="black"
> > stroke-width="1" class="" onmouseover="ShowData(evt)"
> > onmouseout="HideData(evt)">
> > then create ShowData and HideData in a script element. Those
> > function, as
> > their name mean, will show and hide data.
> >
> > J�r�me
> >
> >
> > --- In [EMAIL PROTECTED], "ratee111" <[EMAIL PROTECTED]>
> > wrote:
> > > hi all,
> > > Could anyone help me about show data on rect where mouseover
> and
> > > don't hide where mouseout? now i can do only change color on
rect.
> > > thanks in
> > advance
> > >
> > > <?xml version="1.0" encoding="utf-8"?>
> > > <svg width="400px" height="400px" viewbox="0 0 400 400"
> > > xmlns:xlink="http://www.w3.org/1999/xlink">
> > > <rect x="54" y="266" width="37" height="94" fill="Red"
> > stroke="black"
> > > stroke-width="1" class="" >
> > > <set attributeName="fill" to="blue" begin="mouseover"
> > > end="mouseout"/>
> > > </rect>
> >
> >
> >
> > ------------------------ Yahoo! Groups Sponsor -------------------
-
> ~-->
> > $9.95 domain names from Yahoo!. Register anything.
> > http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/1U_rlB/TM
> > ------------------------------------------------------------------
--
> ~->
> >
> > -----
> > 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
>
>
>
> ------------------------ Yahoo! Groups Sponsor --------------------
~-->
> $9.95 domain names from Yahoo!. Register anything.
> http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/1U_rlB/TM
> --------------------------------------------------------------------
~->
>
> -----
> 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
------------------------ Yahoo! Groups Sponsor --------------------~-->
$9.95 domain names from Yahoo!. Register anything.
http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/1U_rlB/TM
--------------------------------------------------------------------~->
-----
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/