I'm new to SVG and have been playing around with it for a few days now and I have a problem I was hoping someone could help me solve. I tried to drop SVG straight into html (I'm not even sure if this is legal


- Aron
(fyi...I used carto.net as a tutorial, and it was VERY helpful to get me this far)
Code: Select all
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form>
Input Rectangle Width Here:<input type="text" name="width" id="w"/><br />
Input Rectangle Height Here:<input type="text" name="height" id="h"/><br />
<input type="submit" value="Draw Rectangle" onClick="createRect()"/>
</form>
<svg>
<script type="text/ecmascript">
<![CDATA[
var svgNS = "http://www.w3.org/2000/svg";
var xlinkNS = "http://www.w3.org/1999/xlink";
function createRect(){
var newRect = document.createElementNS(svgNS,"rect");
var xx = document.getElementById("w").value;
var yy = document.getElementById("h").value;
newRect.setAttributeNS(null,"width",xx);
newRect.setAttributeNS(null,"height",yy);
newRect.setAttributeNS(null,"fill-opacity",1);
newRect.setAttributeNS(null,"stroke-width",1);
newRect.setAttributeNS(null,"astroke-opacity",1);
newRect.setAttributeNS(null,"fill","white");
newRect.setAttributeNS(null,"stroke","black");
document.getElementById("firstGroup").appendChild(newRect);
};
]]>
</script>
<g id="firstGroup">
<rect x="100" y="100" />
</g>
</svg>
</body>
</html>