www.webdeveloper.com
Results 1 to 3 of 3

Thread: Please help with a JS error

  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Unhappy 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 "v_embed_object is null or not an object" 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>

    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>

  2. #2
    Join Date
    Oct 2008
    Location
    U.S.
    Posts
    726
    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);
    To the following:
    Code:
    if (v_embed_object !== null) {
        v_embed_object.setAttribute("src",v_value_url);
    }
    Last edited by astupidname; 12-08-2009 at 11:00 PM.

  3. #3
    Join Date
    Dec 2009
    Posts
    2

    Smile thanks!

    it worked

    thank you very much for very helpful and quick answer

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles