I want to load the svg file based on a parameter.
e.g., if Parameter = A then load A.svg, if parameter = B then load B.svg, and so on..
For this case, I'm using Codeigniter, so on Model I load the svg file like this:
Model.php
$svgTag = '<div id="svg-content" >'
. '<input type="radio" name="test"/>'
. file_get_contents( APPPATH. 'views/svg/'.$param.'.svg', TRUE)
. '</div>'
After that, I load the $svgTag
on view.
View.php
<html>
<body>
<?php echo $svgTag; ?>
</body>
</html>
My expectation is the svg file will be loaded in the div#svg-content
, but the actual result is that svg is loaded after tag <body>
like this:
RESULT
<html>
<body>
<svg>........</svg> <!-- Loaded SVG File -->
<div id="svg-content" >
<input type="radio" name="test"/>
</div>
</body>
</html>
I wanna add the event on radio button, IF it's clicked, then change the color of SVG image.
IF I use <object>
I cannot apply this style.
NOTE: This is the content of file that I try to load:
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 1280 800" enable-background="new 0 0 1280 800" xml:space="preserve">
<g>
<polygon points="358.3,524.2 328.3,524.2 328.3,665 415,665 415,640 358.3,640 "/>
</g>
</svg>
Is there any way to get the result like this..?
<html>
<body>
<div id="svg-content" >
<input type="radio" name="test"/>
<svg>........</svg> <!-- Loaded SVG File -->
</div>
</body>
</html>