Hi all,
I have some knowledge of html/javascript/vbscript but it has been about 8 years since I have used them. I am dumping some data from tables in an access database in to xml files which I want to read on a webpage.
I am unable to use anything other than client side script to be able to read these (due to restrictions at work which I am working around). I have succesfully managed to do this with javascript however an error keeps coming up on the page. The script works as I intended but I would love for this error to go away.
It is showing as:
Line 23 Char 2 "Object Required"
The specific line is:
My code is as follows (sorry for being so untidy):
I have some knowledge of html/javascript/vbscript but it has been about 8 years since I have used them. I am dumping some data from tables in an access database in to xml files which I want to read on a webpage.
I am unable to use anything other than client side script to be able to read these (due to restrictions at work which I am working around). I have succesfully managed to do this with javascript however an error keeps coming up on the page. The script works as I intended but I would love for this error to go away.
It is showing as:
Line 23 Char 2 "Object Required"
The specific line is:
Code:
var optn = document.createElement("OPTION");
My code is as follows (sorry for being so untidy):
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
<script language="javascript">
function loadDrops(){
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
httpRequest.open("GET", "file://xxx.xxx.xxxxx.net/data$/corp/Nonconformance/Web/XML/tblDept.xml", true);
httpRequest.send()
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = false;
xmlDoc.loadXML(httpRequest.responseText);
departments = xmlDoc.getElementsByTagName("Department")
var z = departments.length
var i=0
var optn = document.createElement("OPTION");
for (i;i<=z;i++)
{
//addOption(document.drop_list.Month_list,xmlDoc.getElementsByTagName("Department").item(i).text,xmlDoc.getElementsByTagName("DeptID").item(i).text)
var optn = document.createElement("OPTION");
optn.text = xmlDoc.getElementsByTagName("Department").item(i).text
optn.value = xmlDoc.getElementsByTagName("DeptID").item(i).text;
selectbox = document.drop_list.Month_list;
selectbox.options.add(optn);
}
sortSelect()
}
</script>
<script language="javascript">
function GrabValue(){
var myindex = document.getElementById("Monthz").selectedIndex
var SelValue = document.getElementById("Monthz").options[myindex].value
document.getElementById("TxtBox").value = SelValue
}
</script>
<script language="javascript">
function sortSelect() {
var tmpAry = new Array();
for (var i=0;i<document.getElementById("Monthz").options.length;i++) {
tmpAry[i] = new Array();
tmpAry[i][0] = document.getElementById("Monthz").options[i].text;
tmpAry[i][1] = document.getElementById("Monthz").options[i].value;
}
tmpAry.sort();
while (document.getElementById("Monthz").options.length > 0) {
document.getElementById("Monthz").options[0] = null;
}
for (var i=0;i<tmpAry.length;i++) {
var op = new Option(tmpAry[i][0], tmpAry[i][1]);
document.getElementById("Monthz").options[i] = op;
}
return;
}
</script>
</head>
<body onLoad="loadDrops()">
<FORM name="drop_list" action="javascript: return false;" method="POST" >
<SELECT NAME="Month_list" id="Monthz" onchange="GrabValue()">
<Option value="1" >Month list</option>
</SELECT> <input type="text" id="TxtBox" name="T1" size="20"></form>
</body>
</html>
Comment