Hello to everyone!
I’m working on a project using JQuery and Keith Woods’ extension to provide SVG functionality.
My final goal is to develop some kind of HMI/SCADA implementation.
My intention is to have an svg graphic representing some kind of process and then change certain shapes parameters from scripting part.
I’m pretty new to Javascript, JQuery and so on. But I’m trying to make my way by reading a lot on internet. However I couldn’t find a clue about my most recent issue.
Mi idea is to embed and svg file created before on Inkspace. This would be the skeleton of the process I want to represent.
Then, from the html document where this svg file is embedded, I want to alter certain parameters of the shapes inside, for instance I want to change the colour of a particular rectangle.
So, I embed the file in the html document like this:
<embed name=“scada” id=“scada” src=“svgfile.svg” type=“image/svg+xml” width=“100%” height=“800”/>
Let’s suppose now, that inside the file “svgfile.svg” I have the following recangle (rect1):
<rect id=“rect1” x=“100” y=“60” rx=“20” ry=“20” width=“100” height=“100” style=“fill:red;stroke:black;stroke-width:5;opacity:0.5”/>
How can I now, from the html document, instance this rectangle to change the “fill” attribute?
For instance, I want to change the colour when I press a button on the html page which calls the following function (inside html javascript code, NOT svg file):
$(‘#link’).click(function(){
// I NEED TO KNOW WHAT TO PUT IN HERE
});
I have found something in here: http: //www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#JavaScript (Specifically in the “Scripting between HTML and SVG” section) but I would rather preffer to use JQuery.
I hope I made myself clear.
Please help me and thanks in advance.
Francisco.