473,545 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

JavaScript, Multiple XML file loading problem, FF/IE

10 New Member
Hello everyone,

Long time lurker, first time poster. I'm a beginner coder, and I've taught myself everything with the help and expertise of users and websites like this one. I normally figure out any problem, but this one really has me stumped.

Basically, I have created a site that initially loads a set of "items" and their values into 17 drop down menus from an XML file. Each of those "items" when selected from the drop down menu loads data into a few arrays, and outputs it to a table. The data is then used for a calculation output, which is the overall goal of the program/site.

Everything works fine up to this point...

Now I'm introducing a button that automatically selects the 17 "items." So basically my application runs through a loop and is supposed to: select each item, load each XML file, interprets each "items" data, save each "item" data to arrays, and then outputs each to the table.

It works fine locally with internet explorer 6, but does not work with Firefox online/local, or IE online. If I add an "alert" somewhere in the loop process, it works, but then I have 17 alerts to deal with. IE online only inputs the last item in the table, and Firefox outputs all 0's locally, and then online Firefox implements mostly all zeros, except for the last and first(which outputs the data of the last instead of the first).

So anyway, my source code is about 2000 lines. You can access my program at http://www.stasistech.com/wow/test/itemdps.html (click the max "i.lvl" button to see the problem)
js: http://www.stasistech.com/wow/test/itemdps.js

Here's the code that somewhere has the problem(i hope!):
Expand|Select|Wrap|Line Numbers
  1. itemSlots=new Array();
  2. itemSlots[0]="head";
  3. itemSlots[1]="shoulders";
  4. ...
  5. itemSlots[16]="relic";
  6.  
  7. //called by the button to select gear
  8. function selectGear(gear)
  9.     {
  10.     switch(gear)
  11.         {
  12.         case "lvl":
  13.             for (j0=0; j0<itemSlots.length; j0++)
  14.                 {
  15.                 document.itemForm.elements[itemSlots[j0]].selectedIndex = 1;
  16.                 loadItem(document.itemForm.elements[itemSlots[j0]],itemSlots[j0])
  17.                 }
  18.             break;
  19.         }    
  20.     }    
  21.  
  22. //loads each item, ignore the unlock step
  23. function loadItem(itemID,slot)
  24.     {
  25. //special flag called by selecting the last item
  26. unlockItemFlag=0;
  27.     //unlocks slot with user input
  28.     if(itemID.options[itemID.selectedIndex].value =="7")unlockSlot(slot); 
  29.     if(unlockItemFlag==0)lockSlot(slot);
  30.     //loads file for each item
  31.     var xmlFileLocation = ('items/'+itemID.options[itemID.selectedIndex].value + '.xml')
  32.     loadXML(xmlFileLocation,1,slot);
  33.     }
  34.  
  35. //XML Loading
  36. function loadXML(xmlFile,type,slot)
  37.     {
  38.     if (detectBrowser()=="IE")
  39.         {
  40.         xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  41.         xmlDoc.onreadystatechange = function () 
  42.             {
  43.             if (xmlDoc.readyState == 4) 
  44.                 {
  45.                 switch(type)
  46.                     {
  47.                     case 0:
  48.                         for(k=0; k<itemSlots.length; k++)
  49.                             {
  50.                             loadItemsIntoMenus(itemSlots[k]);
  51.                             }    
  52.                         break;
  53.                     case 1:
  54.                         loadItemStats(slot,xmlDoc);
  55.                         break;
  56.                     case 2:    
  57.                         fillBox();
  58.                         break;
  59.                     }
  60.                 }    
  61.             };    
  62.         xmlObj=xmlDoc.documentElement;
  63.         }
  64.  
  65.     else if (detectBrowser()=="FF")
  66.         {
  67.         xmlDoc = document.implementation.createDocument("", "", null);
  68.         xmlDoc.load(xmlFile);
  69.         xmlDoc.onload=function()
  70.             {
  71.                 switch(type)
  72.                     {
  73.                     case 0:
  74.                         for(k=0; k<itemSlots.length; k++)
  75.                             {
  76.                             loadItemsIntoMenus(itemSlots[k]);
  77.                             }    
  78.                         break;
  79.                     case 1:
  80.                         loadItemStats(slot,xmlDoc);
  81.                         break;
  82.                     case 2:    
  83.                         fillBox();
  84.                         break;
  85.                     }
  86.             };    
  87.         }
  88.     else
  89.         {
  90.         alert("you can't handle this script! please use firefox or internet explorer")
  91.         }
  92.     xmlDoc.load(xmlFile);
  93.     }
  94.  
  95. //disregard the massive quantity of XML interpretations 
  96. function loadItemStats(slot,xmlDoc)
  97.     {
  98.     //clearItemValues(slot);
  99.     slotNum=slotTextToNum(slot);
  100.     //reset item to zeros
  101.     relicManaReduction=0;
  102.     itemCrit[slotNum]=0;
  103.     itemHit[slotNum]=0;
  104.     itemInt[slotNum]=0;
  105.     itemStam[slotNum]=0;
  106.     itemDmg[slotNum]=0;
  107.     itemMp5[slotNum]=0;
  108.     itemHaste[slotNum]=0;
  109.     socketNumber=0;
  110.     if(slot=="head")metaFlag=0;
  111.     socketFlag=0;
  112.  
  113.  
  114.     //check for sockets
  115.     if (xmlDoc.getElementsByTagName('socket') != null)
  116.         {
  117.         var socketInfo = xmlDoc.getElementsByTagName('socket');
  118.         for (k5=0; k5<socketInfo.length; k5++)
  119.             {
  120.             socketFlag=1;
  121.             socketColors[k5]=socketInfo[k5].getAttribute("color")
  122.             if (socketColors[k5]== "Meta")
  123.                 {
  124.                 metaFlag=1;
  125.                 }
  126.             socketNumber=k5+1;
  127.  
  128.  
  129.             //unlocks gems
  130.             document.itemForm.elements[slot+"Gem"+socketNumber].disabled=false;
  131.  
  132.             }
  133.         //lock out and disable empty sockets
  134.         for (socketsEmpty=k5+1; socketsEmpty <=3; socketsEmpty++)
  135.             {
  136.             if(unlockItemFlag==0)document.itemForm.elements[slot+"Gem"+socketsEmpty].disabled=true;        
  137.             }
  138.         }    
  139.         newGemLoader(slot);
  140. //    alert(xmlDoc.getElementsByTagName("bonusIntellect").item(0).firstChild.data)     
  141.     //check for int
  142.     if (xmlDoc.getElementsByTagName("bonusIntellect").item(0) != null)
  143.         {
  144.         itemInt[slotNum]=xmlDoc.getElementsByTagName("bonusIntellect").item(0).firstChild.data*1;
  145.         }
  146.  
  147.     //check for stam
  148.     if (xmlDoc.getElementsByTagName("bonusStamina").item(0) != null)
  149.         {
  150.         itemStam[slotNum]=xmlDoc.getElementsByTagName("bonusStamina").item(0).firstChild.data*1;
  151.         }
  152.  
  153.     //check for crit
  154.     if (xmlDoc.getElementsByTagName("bonusCritSpellRating").item(0) != null)
  155.         {
  156.         itemCrit[slotNum]=xmlDoc.getElementsByTagName("bonusCritSpellRating").item(0).firstChild.data*1;
  157.         }
  158.  
  159.     //check for hit
  160.     if (xmlDoc.getElementsByTagName("bonusHitSpellRating").item(0) != null)
  161.         {
  162.         itemHit[slotNum]=xmlDoc.getElementsByTagName("bonusHitSpellRating").item(0).firstChild.data*1;
  163.         }
  164.  
  165.     //check for haste
  166.     if (xmlDoc.getElementsByTagName("bonusHasteSpellRating").item(0) != null)
  167.         {
  168.         itemHaste[slotNum]=xmlDoc.getElementsByTagName("bonusHasteSpellRating").item(0).firstChild.data*1;
  169.         }
  170.  
  171.     //itemDamage[slot]=xmlDoc.getElementsByTagName("spellData").item(1).firstChild.data)
  172.     for (k=0; xmlDoc.getElementsByTagName('desc')[k] != null; k++)
  173.         {
  174.         //alert(xmlDoc.getElementsByTagName('desc')[k].lastChild.data);
  175.  
  176.         itemData=xmlDoc.getElementsByTagName('desc')[k].lastChild.data
  177.  
  178.         //Check for +Damage
  179.         if (itemData.match("Increases damage and healing done by magical spells and effects by up to"))
  180.             {
  181.             itemDmg[slotNum]=parseFloat(itemData.substring(itemData.length-4,itemData.length-1));
  182.             }
  183.         //Check for Mana Regen
  184.         else if (itemData.match("Restores "))
  185.             {
  186.             itemMp5[slotNum]=parseFloat(itemData.substring(9,12));
  187.             }
  188.         //check for LB/CL dmg
  189.         else if(itemData.match("Increases damage done by Chain Lightning and Lightning Bolt by up to "))
  190.             {
  191.             itemDmg[slotNum]=parseFloat(itemData.substring(itemData.length-3,itemData.length-1));
  192.             }
  193.         else if(itemData.match("Reduces the mana cost of") && itemData.match("Lightning"))
  194.             {    
  195.             relicManaReduction=parseFloat(itemData.substring(itemData.length-3,itemData.length-1));
  196.             }
  197.         else
  198.             {
  199.             }
  200.         }
  201.         calculateItemStats(slot,slotNum);    
  202.         outputItemStats(slot,slotNum);
  203. //    alert("int:\t" + itemInt[slotNum]+"\n\nstam:\t" + itemStam[slotNum] + "\n\ncrit:\t" + itemCrit[slotNum] + "\n\ndamage:\t" + itemDmg[slotNum] + "\n\nregen:\t" + itemMp5[slotNum])
  204.     }
  205. function calculateItemStats(slot,slotNum)
  206.     {
  207.     totalItemStam[slotNum]=itemStam[slotNum]+itemEnchantStam[slotNum]+itemGem1Stam[slotNum]+itemGem2Stam[slotNum]+itemGem3Stam[slotNum];
  208.     totalItemInt[slotNum]=itemInt[slotNum]+itemEnchantInt[slotNum]+itemGem1Int[slotNum]+itemGem2Int[slotNum]+itemGem3Int[slotNum];
  209.     totalItemDmg[slotNum]=itemDmg[slotNum]+itemEnchantDmg[slotNum]+itemGem1Dmg[slotNum]+itemGem2Dmg[slotNum]+itemGem3Dmg[slotNum];
  210.     totalItemCrit[slotNum]=itemCrit[slotNum]+itemEnchantCrit[slotNum]+itemGem1Crit[slotNum]+itemGem2Crit[slotNum]+itemGem3Crit[slotNum];
  211.     totalItemHit[slotNum]=itemHit[slotNum]+itemEnchantHit[slotNum]+itemGem1Hit[slotNum]+itemGem2Hit[slotNum]+itemGem3Hit[slotNum];
  212.     totalItemMp5[slotNum]=itemMp5[slotNum]+itemEnchantMp5[slotNum]+itemGem1Mp5[slotNum]+itemGem2Mp5[slotNum]+itemGem3Mp5[slotNum];
  213.     totalItemHaste[slotNum]=itemHaste[slotNum]+itemEnchantHaste[slotNum]+itemGem1Haste[slotNum]+itemGem2Haste[slotNum]+itemGem3Haste[slotNum];
  214.     }
  215.  
  216. function outputItemStats(slot,slotNum)
  217.     {
  218.     document.itemForm.elements[slot+"Stam"].value=totalItemStam[slotNum];
  219.     document.itemForm.elements[slot+"Int"].value=totalItemInt[slotNum];
  220.     document.itemForm.elements[slot+"Dmg"].value=totalItemDmg[slotNum];
  221.     document.itemForm.elements[slot+"Crit"].value=totalItemCrit[slotNum];
  222.     document.itemForm.elements[slot+"Hit"].value=totalItemHit[slotNum];
  223.     document.itemForm.elements[slot+"Mp5"].value=totalItemMp5[slotNum];
  224.     document.itemForm.elements[slot+"Haste"].value=totalItemHaste[slotNum];
  225.     }
  226.  
  227.  

Thanks in advance for your help,
-Rob
Jul 18 '07 #1
7 2996
psybert
10 New Member
Anyone have any guidance on what I should do? I've sort of hit a brick wall in the site programming until I can figure this problem out. Any help or direction would be greatly appreciated. Thanks again for your time,
-Rob
Jul 20 '07 #2
psybert
10 New Member
Anyone have any guidance on what I should do? I've sort of hit a brick wall in the site programming until I can figure this problem out. Any help or direction would be greatly appreciated. Thanks again for your time,
-Rob
Bump~ ! I figure it's the weekend, maybe It will get some more visibility.
Jul 21 '07 #3
drhowarddrfine
7,435 Recognized Expert Expert
All I can add is that there are 132 HTML errors and no doctype so IE is in quirks mode.
Jul 22 '07 #4
psybert
10 New Member
All I can add is that there are 132 HTML errors and no doctype so IE is in quirks mode.
I went in and fixed all of them. Thanks for the tip. Unfortunately the page still doesn't work :(
Jul 22 '07 #5
kovik
1,044 Recognized Expert Top Contributor
If it works offline, but not online, maybe you're accessing the file incorrectly.

And if your code doesn't work at all in Firefox, then the code that you've specified in your FF branch is probably incorrect.
Jul 22 '07 #6
psybert
10 New Member
If it works offline, but not online, maybe you're accessing the file incorrectly.

And if your code doesn't work at all in Firefox, then the code that you've specified in your FF branch is probably incorrect.
The problem only comes about when i try to loop the whole process. If i change and add each item manually it comes up fine. In fact if I add an "alert" in the loop process, it slows it down enough to actually work.
Jul 23 '07 #7
psybert
10 New Member
anyone have any more ideas? :(
Jul 27 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

53
5660
by: Cardman | last post by:
Greetings, I am trying to solve a problem that has been inflicting my self created Order Forms for a long time, where the problem is that as I cannot reproduce this error myself, then it is difficult to know what is going on. One of these Order Forms you can see here... http://www.cardman.co.uk/orderform.php3
4
3818
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following beautiful script "http://javascript.internet.com/navigation/toolbar-menu.html". It works like a charm. I made my webpage in frames, where the...
3
8485
by: Roy Wang | last post by:
hi, My problem is how to determining when the XML file has loaded using javascript. I loaded an xml file using javascript in a web page. The code below is loading the xml file for IE: this.xmlDoc= new ActiveXObject("Microsoft.DomDocument"); this.xmlDoc.load(url);
6
4967
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a...
3
3341
by: jimmygoogle | last post by:
I posted earlier with a scope problem. I think I resolved it in IE but in Firefox it still exists. Anyone have any ideas/experience with this? I attached my code sorry it is so long. You can cut/paste it into 2 files and run it to see what I mean. ###############menu.html############### <html> <body> <script type="text/javascript">
1
3786
by: ozzy.osborn | last post by:
Hello All, I have been struggling with a cross browser solution to loading external javascript files on the fly. I have been successful using the following code in IE6: var newScr = document.createElement("SCRIPT"); newScr.src = "newScr.js"; newScr.type="text/javascript";
22
2290
by: Christopher Nelson | last post by:
I have a little menu system which essentially takes HTML like: <div id='foo'></div> and retrieves foo.shtml from the server and inserts it inside the <div>. But sometimes I'd like foo.shtml to look like: <script language='JavaScript'> ...do something AJAX-y </script>
3
2260
by: GroupReader | last post by:
I posted a similar question earlier and got lots of good feedback, but now I have more information: Problem: I have javascript in a user control that is not "loading" properly. When I try to call the script from my page, I get "object not found". Temporary Workaround: This only happens when I have "debug=true" in my web.config. If I...
0
7484
marktang
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...
0
7415
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7928
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7440
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...
0
5997
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5344
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
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
0
726
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.