/    Sign up×
Community /Pin to ProfileBookmark

Please help with a JS error

Hello,

i have some oracle API by which i am able to generate web pages with some stats displayed by charts which can be viewed by the end clients.

But i am having trouble with one JS method which is being used for the dynamic update of the type of the chart.

I get “[B]v_embed_object is null or not an object[/B]” during execution of this code:

[CODE]<SCRIPT LANGUAGE=”JavaScript”>
function changeGraphType(p_graph_id,p_type){

v_value_url = “MyTestCharts.swf?p_chart_code=”+p_type;

v_chart_object = document.getElementById(p_graph_id);

v_movie_object = document.getElementById(“movie_”+p_graph_id);
v_embed_object = document.getElementById(“embed_”+p_graph_id);

v_movie_object.setAttribute(“value”,v_value_url);
v_embed_object.setAttribute(“src”,v_value_url);

}
</script>
[/CODE]

I think it is quite obvious error for an expert but i am the complete newbie in JS.. ?

to make things simplier i can provide the full code of the generated page:

[CODE]
<HTML>
<BODY>
<SCRIPT LANGUAGE=”JavaScript”>
function changeGraphType(p_graph_id,p_type){

v_value_url = “MyTestCharts.swf?p_chart_code=”+p_type;

v_chart_object = document.getElementById(p_graph_id);

v_movie_object = document.getElementById(“movie_”+p_graph_id);
v_embed_object = document.getElementById(“embed_”+p_graph_id);

v_movie_object.setAttribute(“value”,v_value_url);
v_embed_object.setAttribute(“src”,v_value_url);

}
</script>
<div id=”switchCharts”>
<form id=”selectForm”>
<select onchange=”javascript:changeGraphType(‘DemoChart’,this.value);”>
<option value=”AR2DF”>2D Area Chart</option>
<option value=”BC2DF”>2D Bar Chart</option>
<option value=”CL2DF”>2D Column Chart</option>
<option value=”CL3DF”>3D Column Chart</option>
<option value=”DN2DF”>2D Doughnut Chart</option>
<option value=”PI2DF”>2D Pie Chart</option>
<option value=”PI3DF”>3D Pie Chart</option>
<option value=”LINEF”>Line Chart</option>
</select>
</form>
</div>
<div id=”chartdiv”>
<object classid=”clsid:D27CDB6E-AE6D-11cf-96B8-444553540000″ codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0″ width=”800″ height=”600″ id=”DemoChart” >
<param id=”movie_DemoChart” name=”movie” value=”MyTestCharts.swf?p_chart_code=AR2DF” />
<param id=”FlashVars_DemoChart” name=”FlashVars” value=”&dataURL=singleSeriesChartData.xml&chartWidth=800&chartHeight=600″>
<param id=”quality_DemoChart” name=”quality” value=”high” />
<embed id=”embed_DemoChart” src=”MyTestCharts.swf?p_chart_code=AR2DF” flashVars=”&dataURL=singleSeriesChartData.xml&chartWidth=800&chartHeight=600″ quality=”high” width=”800″ height=”600″ name=”DemoChart” type=”application/x-shockwave-flash” pluginspage=”http://www.macromedia.com/go/getflashplayer” />
</object>
</div>
</BODY>
</HTML>
[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@astupidnameDec 09.2009 — Although you have not said so, I presume the error occurs in IE. IE does not recognize the non-standard embed tag (which is supported by other browsers) and won't even see it when it searches the pages elements for one with the given id if the id is in an embed tag, so v_embed_object is therefore null (in IE), and not needed in IE anyhow. So get around it with an 'if' conditional:

Change:
v_embed_object.setAttribute("src",v_value_url);[/quote]
To the following:
if (v_embed_object !== null) {
v_embed_object.setAttribute("src",v_value_url);
}
Copy linkTweet thisAlerts:
@ms-hotspotauthorDec 09.2009 — it worked ?

thank you very much for very helpful and quick answer
×

Success!

Help @ms-hotspot spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.28,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...