Alright this runs just fine in IE but in firefox I get nothing -
function startup()
-
{
-
if (window.ActiveXObject)
-
{
-
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
-
}
-
else if (document.implementation.createDocument)
-
{
-
xmlDoc=document.implementation.createDocument("","",null);
-
}
-
else
-
{
-
alert('Your browser cannot handle this script');
-
}
-
if (xmlDoc!=null)
-
{
-
xmlDoc.async=false;
-
xmlDoc.load("XML/faq.xml");
-
var x=xmlDoc.getElementsByTagName("QUES");
-
for (i=0;i<x.length;i++)
-
{
-
t = x[i].getElementsByTagName("CAT")[0].childNodes[0].nodeValue;
-
categories.push(t);
-
}
-
var categoryList = categories.unique();
-
-
for (var i=categoryList.length-1; i>=0; --i )
-
{
-
selectCategory.options[i]=new Option(categoryList[i], i, true, false);
-
}
-
-
sizeOfCats = selectCategory.options.length;
-
selectCategory.options[sizeOfCats]=new Option("Select", sizeOfCats, true, true);
-
-
}
-
}
-
-
Array.prototype.unique = function()
-
{
-
var r = new Array();
-
o:for(var i = 0, n = this.length; i < n; i++)
-
{
-
for(var x = 0, y = r.length; x < y; x++)
-
{
-
if(r[x]==this[i])
-
{
-
continue o;
-
}
-
}
-
r[r.length] = this[i];
-
}
-
return r;
-
}
-
-
function clearSelect()
-
{
-
selectQuestion.options.length = 0;
-
}
-
-
function loadSelectQuestion()
-
{
-
questions = [];
-
theAnswer.innerHTML="";
-
var theCategory = selectCategory.options[selectCategory.selectedIndex].text;
-
if(theCategory != "Select")
-
{
-
divSelectQuestion.innerHTML = "<p>Select a Question:</p><select id=\"selectQuestion\" onchange=\"loadAnswer()\"></select><br/><br/>";
-
var x=xmlDoc.getElementsByTagName("QUES");
-
for (i=0;i<x.length;i++)
-
{
-
aCategory = x[i].getElementsByTagName("CAT")[0].childNodes[0].nodeValue;
-
-
if(aCategory == theCategory)
-
{
-
aQuestion = x[i].getElementsByTagName("Q")[0].childNodes[0].nodeValue;
-
questions.push(aQuestion);
-
for (var j=questions.length-1; j>=0; --j )
-
{
-
selectQuestion.options[j]=new Option(questions[j], j, true, false)
-
}
-
}
-
else
-
{
-
-
}
-
}
-
-
sizeOfQues = selectQuestion.options.length;
-
selectQuestion.options[sizeOfQues]=new Option("Select", sizeOfQues, true, true);
-
-
}
-
else
-
{
-
divSelectQuestion.innerHTML = "";
-
}
-
}
-
-
function loadAnswer()
-
{
-
var theQuestion = selectQuestion.options[selectQuestion.selectedIndex].text;
-
var x=xmlDoc.getElementsByTagName("QUES");
-
for (i=0;i<x.length;i++)
-
{
-
aQuestion = x[i].getElementsByTagName("Q")[0].childNodes[0].nodeValue;
-
-
if(aQuestion == theQuestion)
-
{
-
anAnswer = x[i].getElementsByTagName("A")[0].childNodes[0].nodeValue;
-
theAnswer.innerHTML = "Answer:<br/><br/>" + anAnswer + "<br/><br/>";
-
}
-
}
-
}
-
-
</script>
-
-
thanks for your time.
8 1888
After doing some more debugging I tried to tune the code a little -
<script type="text/javascript">
-
var categories = new Array();
-
var questions = new Array();
-
var xmlDoc=null;
-
var firstTime;
-
var sizeOfCats;
-
var sizeOfQues;
-
-
function readFile()
-
{
-
if (xmlDoc!=null)
-
{
-
var x=xmlDoc.getElementsByTagName("QUES");
-
for (i=0;i<x.length;i++)
-
{
-
t = x[i].getElementsByTagName("CAT")[0].childNodes[0].nodeValue;
-
categories.push(t);
-
}
-
var categoryList = categories.unique();
-
-
for (var i=categoryList.length-1; i>=0; --i )
-
{
-
selectCategory.options[i]=new Option(categoryList[i], i, true, false);
-
}
-
-
sizeOfCats = selectCategory.options.length;
-
selectCategory.options[sizeOfCats]=new Option("Select", sizeOfCats, true, true);
-
-
}
-
-
}
-
-
function startup()
-
{
-
divSelectCategory.innerHTML = "<select id=\"selectCategory\" onchange=\"loadSelectQuestion()\"></select>";
-
-
if (window.ActiveXObject)
-
{
-
xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
-
xmlDoc.async=false;
-
xmlDoc.load("XML/faq.xml");
-
readFile();
-
}
-
else if (document.implementation.createDocument)
-
{
-
xmlDoc = document.implementation.createDocument("", "", null);
-
xmlDoc.onload = readFile();
-
xmlDoc.load("XML/faq.xml");
-
}
-
else
-
{
-
alert('Your browser cannot handle this script');
-
}
-
}
-
-
Array.prototype.unique = function()
-
{
-
var r = new Array();
-
o:for(var i = 0, n = this.length; i < n; i++)
-
{
-
for(var x = 0, y = r.length; x < y; x++)
-
{
-
if(r[x]==this[i])
-
{
-
continue o;
-
}
-
}
-
r[r.length] = this[i];
-
}
-
return r;
-
}
-
-
function clearSelect()
-
{
-
selectQuestion.options.length = 0;
-
}
-
-
function loadSelectQuestion()
-
{
-
questions = [];
-
theAnswer.innerHTML="";
-
var theCategory = selectCategory.options[selectCategory.selectedIndex].text;
-
if(theCategory != "Select")
-
{
-
divSelectQuestion.innerHTML = "<p>Select a Question:</p><select id=\"selectQuestion\" onchange=\"loadAnswer()\"></select><br/><br/>";
-
var x=xmlDoc.getElementsByTagName("QUES");
-
for (i=0;i<x.length;i++)
-
{
-
aCategory = x[i].getElementsByTagName("CAT")[0].childNodes[0].nodeValue;
-
-
if(aCategory == theCategory)
-
{
-
aQuestion = x[i].getElementsByTagName("Q")[0].childNodes[0].nodeValue;
-
questions.push(aQuestion);
-
for (var j=questions.length-1; j>=0; --j )
-
{
-
selectQuestion.options[j]=new Option(questions[j], j, true, false)
-
}
-
}
-
else
-
{
-
-
}
-
}
-
-
sizeOfQues = selectQuestion.options.length;
-
selectQuestion.options[sizeOfQues]=new Option("Select", sizeOfQues, true, true);
-
-
}
-
else
-
{
-
divSelectQuestion.innerHTML = "";
-
}
-
}
-
-
function loadAnswer()
-
{
-
var theQuestion = selectQuestion.options[selectQuestion.selectedIndex].text;
-
var x=xmlDoc.getElementsByTagName("QUES");
-
for (i=0;i<x.length;i++)
-
{
-
aQuestion = x[i].getElementsByTagName("Q")[0].childNodes[0].nodeValue;
-
-
if(aQuestion == theQuestion)
-
{
-
anAnswer = x[i].getElementsByTagName("A")[0].childNodes[0].nodeValue;
-
theAnswer.innerHTML = "Answer:<br/><br/>" + anAnswer + "<br/><br/>";
-
}
-
}
-
}
-
-
</script>
-
-
Now this works in IE but in firefox it doesn't...
the error the error console gives is
Error: divSelectCatego ry is not defined
Source File: file:///C:/Users/Administrator/Desktop/CRC/crcFAQ.html
Line: 42
Anyways hope that helps you to help me :D
Hi i think the problem may be in the line - xmlDoc.onload = readFile();
-
xmlDoc.load("XML/faq.xml");
Can you please check on this.
Regards
Ramanan Kalirajan
acoder 16,027
Recognized Expert Moderator MVP
The problem is line 35. divSelectCatego ry hasn't been defined anywhere.
@acoder
In my html I have a div with the id divSelectCatego ry, shouldnt that mean it's defined? (new to javascript sorry)
acoder 16,027
Recognized Expert Moderator MVP
No. You need to access it with: - document.getElementById("divSelectCategory")
acoder 16,027
Recognized Expert Moderator MVP
No problem. Glad it's working :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: fogwolf |
last post by:
First a basic outline of what I am trying to do:
I want to have a page spawn a pop-up when you click "submit" on its
form. On this pop-up page there will be another form. When you click
"submit" on the pop-up's form I want the pop-up to close & a new page
to load in the "parent" window/page. I have this working in IE but
cannot get it to work in Firefox. The parent window correctly loads
the new page after submitting from the pop-up,...
|
by: Adrian Parker |
last post by:
I have a php page which uses checks to see if the tz variable is in the
argument list.. if not, it recalls the page using javascript with the added
tz argument.. if I run it locally here in the UK, the tz is set to 0 which
is correct. If I run it on a US server, it initially returns -1, but in IE
if I do a ctrl-refresh, it correctly gets it as 0.
Any ideas ?
<?php
if (!isset($_GET)) print "
|
by: Franz |
last post by:
Hy all,
I have a problem with a date in javascript on firefox Browser.
I use this javascript method:
var dataNow=new Date();
var dd=dataNow.getDate();
var mm=dataNow.getMonth()+1;
var yy=dataNow.getYear();
|
by: paul |
last post by:
HI! I keep on getting this error and I have tried different things but I am
not sure how to send the expiring date.
The error that I am getting in Firefox 1.5 is
"Error: expires.toGMTString is not a function"
----------------------------------------------------
I have this in a .js file and in the head section.
|
by: Jan Tovgaard |
last post by:
Hey everyone:)
We have a critical problem, which I can see that other people also has ran
into.
In Internet Explorer 7 it is no longer possible to do a window.close after
opening a window,
without getting a alert message that ask if u want to close the window.
This did NOT happen in Internet Explorer 6, Mozilla firefox or other
browsers.
| |
by: jesdynf |
last post by:
I'm having trouble applying a stylesheet to content I'm generating
after the fact.
Here's the sample code:
<html>
<head>
<title>CSS/DOM Problem Example</title>
<style type="text/css">
..historylinks {
|
by: Eric |
last post by:
I have a user of a web application written in Java/JSP that is unable
to login to the site simply because certain links on the page do not
run when they are clicked. Other popups using Javascript on the same
page work correctly.
It appears to be isolated to 1-2 machines in a particular network. I
cannot verify whether these machines have had virus/spyware scans, but
I do know the user is running Firefox 2.1 and IE 7 with the same...
|
by: tim |
last post by:
I am using foldoutmenu 3 and am having problems with viewing my menus
in firefox. On my sub3 menus i have more than one line of text in some
places. firefox does not recognise that there is more than one line
and the text simply overlaps the sub-menus below it. I thought i had
got around this by placing empty 'spacers' like so;
oFoldMenu.make('sub3','')//spacer
unfortunately, i have just viewed the site in IExplorer and it has
added...
|
by: ICPooreMan |
last post by:
I've got some code which works in firefox that's giving me fits in
IE7 (maybe other versions too I haven't tested it). What I want to do
is get the oncontextmenu attribute of something, change the value then
put it back as the oncontextmenu attribute.
Here's an example page if you want to try it out...
<html>
<head>
<titletesting </title>
<script><!--
|
by: Steve |
last post by:
Just a warning to the group. The Google Toolbar causes Firebug to
issue lots of "Too much recursion" errors in the toolbar.js and
eventual causes my Firefox browser to stop responding when using the
javascript window.open method. Removing the Google Toolbar fixes the
problem.
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |