I have the following code working but I am trying to have add another rectangle (mySecondRect) and when you click on the second rectangle it “stores” the red color then when you click on myFirstRect that is when the color of the myFirstRect changes to red.
Similar to an online coloring book. You pick the color and then you want to fill the other rectangle with that color onClick…
I hope that makes sense and any assistance would be greatly appreciated!
lab12
[CODE]<svg xmlns=”http://www.w3.org/2000/svg” xmlns:xlink=”http://www.w3.org/1999/xlink” width=”300″ height=”300″>
<script type=”text/ecmascript”>
<![CDATA[
function changeRectColor(evt) {
evt.target.setAttributeNS(null,”fill”,”red”);
}
]]>
</script>
<g id=”firstGroup”>
<rect id=”myFirstRect” width=”100″ height=”50″ x=”40″ y=”20″ fill=”blue” onclick=”changeRectColor(evt)”/>
</g>
</svg>