Dynamically inserting SVG in JavaScript [Archive] - XML Elves

Dynamically inserting SVG in JavaScript

Kavitha
07-21-2005, 01:52 AM
I am calling this draw() function when i click on submit button from html page
The problem is when i click on submit button , js error is displaying that...... at line 23 shown in comments... that "Object doesnot support this property or method"


This is my Javascript MyScript.js

function draw()
{
document.getElementById('svgdoc').innerHTML = '<embed id = "emb_svg" name="barChart" height="400" src="Trial.svg" width="400" >';

value1 = 50;
value2 = 75;
var x1 = 98;
var x2 = 166;
var barWidth = 10;
var lineBottom = 270;
var lineLeftmargin = 30;
var maxBarTop = lineBottom - lineLeftmargin
var maxInputValue = 100;
var width1 = 35;
var width2 = 35;
var height1 = ((value1 * maxBarTop) / maxInputValue);
var y1 = lineBottom - height1;
var height2 = ((value2 * maxBarTop) / maxInputValue);
var y2 = lineBottom - height2;
var dupsvg=document.barChart.getSVGDocument();
/* line23 */ dupsvg.getElementById("Bar1").setAttribute("x",x1);
dupsvg.getElementById("Bar1").setAttribute("y",y1);
dupsvg.getElementById("Bar1").setAttribute("width",width1);
dupsvg.getElementById("Bar1").setAttribute("height",height1);
dupsvg.getElementById("Bar2").setAttribute("x",x2);
dupsvg.getElementById("Bar2").setAttribute("y",y2);
dupsvg.getElementById("Bar2").setAttribute("width",width2);
dupsvg.getElementById("Bar2").setAttribute("height",height2);

}

Help me ...............
Thanks
Kavitha

flo
07-21-2005, 02:37 AM
Check with alert() if dupsvg is null and if dupsvg.getElementById("Bar1") is null.

Kavitha
07-21-2005, 03:13 AM
I have checked with alert(dupsvg)
But the alert is not getting displayed
When i load the html page the js error as "Object doesnot support this property or method " is showing.

Anonymous
07-23-2005, 06:03 PM
I am calling this draw() function when i click on submit button from html page
The problem is when i click on submit button , js error is displaying that...... at line 23 shown in comments... that "Object doesnot support this property or method"


This is my Javascript MyScript.js

function draw()
{
document.getElementById('svgdoc').innerHTML = '<embed id = "emb_svg" name="barChart" height="400" src="Trial.svg" width="400" >';

value1 = 50;
value2 = 75;
var x1 = 98;
var x2 = 166;
var barWidth = 10;
var lineBottom = 270;
var lineLeftmargin = 30;
var maxBarTop = lineBottom - lineLeftmargin
var maxInputValue = 100;
var width1 = 35;
var width2 = 35;
var height1 = ((value1 * maxBarTop) / maxInputValue);
var y1 = lineBottom - height1;
var height2 = ((value2 * maxBarTop) / maxInputValue);
var y2 = lineBottom - height2;
var dupsvg=document.barChart.getSVGDocument();
/* line23 */ dupsvg.getElementById("Bar1").setAttribute("x",x1);
dupsvg.getElementById("Bar1").setAttribute("y",y1);
dupsvg.getElementById("Bar1").setAttribute("width",width1);
dupsvg.getElementById("Bar1").setAttribute("height",height1);
dupsvg.getElementById("Bar2").setAttribute("x",x2);
dupsvg.getElementById("Bar2").setAttribute("y",y2);
dupsvg.getElementById("Bar2").setAttribute("width",width2);
dupsvg.getElementById("Bar2").setAttribute("height",height2);

}

Help me ...............
Thanks
Kavitha

Hacc
08-11-2005, 12:21 AM
If you don't get the alert means you get the error before the alert. Put an alert before and after document.getElementById('svgdoc').innerHTML. Also try it before and after
var dupsvg=document.barChart.getSVGDocument();

I have checked with alert(dupsvg)
But the alert is not getting displayed
When i load the html page the js error as "Object doesnot support this property or method " is showing.

 
Web mp2kmag.com
mapforums.com

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum