leearach2004
Technical User
Hi there all, I have this problem that I have scoured the internet for but cannot fined any answers for.
I have created a web page that uses javascript to query a ms access database and return the required data to a web form (this is hidden).
I then have an embedded flash movie on the page. I have another javascript function that sends and recieves variables from the flash movie file.
The data from the hidden form is sent to a variable in the flash movie and displayed. This all works fine but occasionaly when it runs it displays an error saying
Document.getElementByID() is null or not an object
but if you close the browser and reopen it works fine and will carryon working fine for ages till randomly you open the .html file and it shows the error again
the code is shown below
maybee i have done somthi g wrong with the order they initalise or somthing
hope somone can help me its so frustrating and i can not distribute if it falls to run one in every ten or so times
lee
I have created a web page that uses javascript to query a ms access database and return the required data to a web form (this is hidden).
I then have an embedded flash movie on the page. I have another javascript function that sends and recieves variables from the flash movie file.
The data from the hidden form is sent to a variable in the flash movie and displayed. This all works fine but occasionaly when it runs it displays an error saying
Document.getElementByID() is null or not an object
but if you close the browser and reopen it works fine and will carryon working fine for ages till randomly you open the .html file and it shows the error again
the code is shown below
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml"[/URL] xml:lang="en" lang="en">
<head>
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<META HTTP-EQUIV="imagetoolbar" CONTENT="NO">
<SCRIPT LANGUAGE=JavaScript>
//load variable from html textarea to flash
<!--
function doPassVar(){
var sendText = form1.sendText.value;
window.document.myFlash.SetVariable("myVar", sendText);
}
//send a variable to flash
function ReceiveDataFromFlashMovie()
{
var mess=myFlash.GetVariable("/:mess");
window.document.form1.title.value=mess;
}
//-->
</SCRIPT>
<script type="text/javascript">
<!--
//create databse connection and variables
var adOpenDynamic = 2;
var adLockOptimistic = 3;
var conn_str = "Provider=Microsoft.Jet.OLEDB.4.0; Ole DB Services=-4; Data Source=\\test\\fyptext.mdb";
var conn = new ActiveXObject("ADODB.Connection");
conn.open(conn_str, "", "");
//open information from database
function rs2arr(rs, arr) {
for(var i=0; i!= rs.fields.count; ++i)
arr[rs.fields(i).name] = rs.fields(i).value
}
//display main selection from database in a form
function show_fyp() {
// write the HTML for the form
var html = ''
html += '<p><div> <input type="hidden" id="fyp_subject" READONLY class="fyp_title_desinfo"/></p>'
document.getElementById("main").innerHTML = html
//run database information collection function
get_fyp();
}
//function to call information from database acording to selection required
function get_fyp() {
var data = new Array()
//select record number
id = form1.title.value;
//select record from database
var rs = new ActiveXObject("ADODB.Recordset")
//' added for test not needed for numbers
rs.open ("SELECT * FROM fyptext WHERE going ='" + id + "'",conn)
rs2arr(rs, data)
rs.close()
// Read the resulting transaction state into the form
document.getElementById("fyp_subject").value = data["subject"]
document.getElementById("fyp_description").value = data["description"]
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<title>javascript_to_flash</title>
<link href="file:///D|/test/fyp.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #FF9900;
}
-->
</style></head>
<body oncontextmenu="return false;" onload="ReceiveDataFromFlashMovie(); show_fyp(); doPassVar(); " MARGINWIDTH="0" MARGINHEIGHT="0" LEFTMARGIN="0" RIGHTMARGIN="0" TOPMARGIN="0" BOTTOMMARGIN="0">
<form name="form1" id="form1" method="post" action="" >
<input type="hidden" name="title" value-"" class="flash_vis">
<input type="hidden" name="sendText" id="fyp_description" class="flash_vis">
</form>
<!--url's used in the movie-->
<!--text used in the movie-->
<p align="center">
<!-- load flash embbeded object -->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="[URL unfurl="true"]http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0"[/URL] id="myFlash" width="100%" height="100%" align="middle">
<param name="allowScriptAccess" value="always" />
<param name="movie" value="javascript_to_flash.swf" />
<param name="quality" value="high" />
<param name="menu" value="false" />
<embed name="myFlash" src="javascript_to_flash.swf" quality="high" height="100%" width="100%" scale="exactfit" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] swLiveConnect="true"/>
</object>
</p>
<div id="main"/>
<!-- activate flash script -->
<script type="text/javascript" src="flashfix.js"></script>
</body >
</html>
maybee i have done somthi g wrong with the order they initalise or somthing
hope somone can help me its so frustrating and i can not distribute if it falls to run one in every ten or so times
lee