XML Elves

XML Elves

<community>of XML and SVG Developers</community>


Dynamically inserting SVG in JavaScript

This is a discussion on Dynamically inserting SVG in JavaScript within the SVG Questions forums, part of the SVG Forums category; I am calling this draw() function when i click on submit button from html page The problem is when i ...


Go Back   XML Elves > SVG Forums > SVG Questions

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices


Click here to register

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-21-2005, 01:52 AM
Kavitha
Guest
 
Posts: n/a
Default Dynamically inserting SVG in JavaScript

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-21-2005, 02:37 AM
flo
Guest
 
Posts: n/a
Default Dynamically inserting SVG in JavaScript

Check with alert() if dupsvg is null and if dupsvg.getElementById("Bar1") is null.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-21-2005, 03:13 AM
Kavitha
Guest
 
Posts: n/a
Default Dynamically inserting SVG in JavaScript

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-23-2005, 06:03 PM
Anonymous
Guest
 
Posts: n/a
Default Re: Dynamically inserting SVG in JavaScript

Quote:
Originally Posted by Kavitha
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 08-11-2005, 12:21 AM
Junior Member
 
Join Date: Jul 2005
Posts: 10
Send a message via Yahoo to Hacc
Default Dynamically inserting SVG in JavaScript

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();

Quote:
Originally Posted by Kavitha
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.
__________________
rogramming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. (Rich Cook)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
dynamically, inserting, javascript, svg


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -6. The time now is 09:16 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0

Canon Pixma Ink Cartridges
Here is a good site for Canon Pixma ink cartridges.

printer inks
We stock printer inks for all the major brands. Quality and value, the perfect combination. Free delivery and freephone too!

Hard Disk Drive Repair Recovery Manchester >>
Data Clinic performs data recovery and repairs on any crashed hard drives.

Hosting services...
Visit this site for hosting services done by professionals.

Web Development Manchester
Web development has revolutionised the way we do business. These guys in Manchester will help you.

ink cartridges Free UK Delivery on ink cartridges such as Canon, Dell, Epson, hp & Lexmark.

1 2 3 4 5 6 7 8 9