473,796 Members | 2,599 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE syntax error, 80020101 and undefined array

67 New Member
Well guys,

I have tested a script that's working well in FF, however while testing with IE7, I am finding errors. That famous yellow warning icon at the left of our status bar.

Basically, I am opening a new popup window using dhtmlgoodies modal message tool. It opens well in FF, however in IE, the yellow icon appears with a bunch of erros as soon as the new window opens up.

The erros are -

1. Syntax error, line 3, character 6.
2. Could not complete the operation due to error 80020101, line 94, character 6
3. chocArray is undefined, line 71, character 1

Now here chocArray is an array I am defining in the page that opens. Strange is, when I call the page (the popup) directly using the browse, I don't see any of these errors, but when I call the page by clicking a link in the parent page, the erros come up.

I could not see anything in line 3, where the first three lines in the page (popup) reads -

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head>
Error 2, 80020101, if I have understood well by googling since the morning and by hit and trial method, is probably from error 1.

Line 71 reads (I'm giving line 57 to 72 here, space removed, so there are fewer lines here) -

<body>

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">        
  2. <!--
  3. var inter_52 = document.getElementById('chocQnty_52');
  4. if (inter_52 && inter_52.value) {
  5. var cqnty_52 = inter_52.value;
  6. } else {
  7. var cqnty_52 = 0;
  8. }                        
  9. chocArray[0] = cqnty_52 + "~" + 79;
  10. ajaxArr[0] = 52 + "~" + cqnty_52;        
  11. //-->        
  12. </script>
  13. <img src="img/spacer.gif" width="1" height="1" onload="subChoc('chocQnty_52','totale_52',79,chocArray,0,'',52,ajaxArr);" />
Any help would be highly appreciated. I am pulling out my hair since this morning 9 o'clock, and it's 7 pm now :(
Dec 18 '07 #1
14 44849
kigoobe
67 New Member
OK, it's 1 am now, and I thought to give another update with some more information, if someone can help.

I have now tested this in Safari 3, Opera 9.24, IE7 and IE6, Netscape 8.1 and 9.0.0.5, and Firefox 2.0.0.11.

Of those, the script is working only in Firefox 2.0.0.11 and Netscape 9.0.0.5 and for the rest, I am having similar bugs.

Here I am adding the full popup page (html version), just incase someone wants to have a look.

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head>
  4. <title>Commande</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <script type="text/javascript" src="js/kajax.js"></script>
  7.  
  8. <script type="text/javascript">
  9. <!--
  10. var chocArray = new Array();
  11. var ajaxArr = new Array();
  12.  
  13.     function subChoc(qnty,totale,prix,chocArray,count,action,id,ajaxArr) {
  14.         chocobox = document.getElementById(qnty);
  15.         chocoPrice = document.getElementById(totale);
  16.         chocoTotal = document.getElementById('gr_totale');
  17.         if (chocobox && chocobox.value && chocoPrice && chocoPrice.innerHTML && action) {
  18.             if ( (action == 'plus') || ((action == 'minus') && (chocobox.value != 0)) || (action == '') ) {
  19.                     if (action == 'plus') {
  20.                         chocobox.value = Number(chocobox.value)+1;
  21.                     } else if (action == 'minus') {
  22.                         chocobox.value = Number(chocobox.value)-1;
  23.                     } else if (action == '') {
  24.                         chocobox.value = Number(chocobox.value);
  25.                     } 
  26.                 ajaxArr[count] = (Number(id) + "~" + chocobox.value);                
  27.                 chocoPrice.innerHTML = Number(prix) * Number(chocobox.value);
  28.                 chocArray[count] = chocobox.value + "~" + chocoPrice.innerHTML;                
  29.                 var total = 0; var price = 0;
  30.                 for(var i=0;i<chocArray.length;i++) {
  31.                     var splitMe = chocArray[i].split("~");
  32.                     if (Number(splitMe[0]) == 0) {
  33.                         price = 0;
  34.                     } else {
  35.                         price = Number(splitMe[1]);
  36.                     }
  37.                     total = Number(total) + Number(price);
  38.                 }
  39.                 chocoTotal.innerHTML = total;
  40.                 var strValue = ajaxArr.join(";");
  41.                 hidvalue = document.getElementById('quote_values');
  42.                 hidvalue.value = strValue;
  43.             } else {
  44.                 chocobox.value = chocobox.value;
  45.             }
  46.         }
  47.     }
  48.  
  49.     function resetArray() {
  50.         chocArray.length = 0;
  51.     }
  52.  
  53.  
  54. //-->
  55. </script>
  56. </head>
  57.  
  58. <body>
  59.  
  60.                     <script type="text/javascript">        
  61.                     <!--
  62.                         var inter_52 = document.getElementById('chocQnty_52');
  63.                         if (inter_52 && inter_52.value) {
  64.                             var cqnty_52 = inter_52.value;
  65.                         } else {
  66.                             var cqnty_52 = 0;
  67.                         }                        
  68.                         chocArray[0] = cqnty_52 + "~" + 79;
  69.                         ajaxArr[0] = 52 + "~" + cqnty_52;        
  70.                     //-->        
  71.                     </script>
  72.  
  73.                     <img src="img/spacer.gif" width="1" height="1" onload="subChoc('chocQnty_52','totale_52',79,chocArray,0,'',52,ajaxArr);" />
  74.  
  75. <form name="ajax" id="ajax" method="post" action="#" enctype="application/x-www-form-urlencoded">
  76.     <div class="myCommande">
  77.  
  78.         <table>
  79. <tr><th>Qté</th><th>Produits</th><th>Prix</th><th>Total</th></tr>
  80. <tr>
  81. <td class="price"><a href="#" onclick="subChoc('chocQnty_52','totale_52',79,chocArray,0,'minus',52,ajaxArr);return false;">-</a> <input type="text" id="chocQnty_52" size="1" maxlength="4" value="1" readonly="readonly" /><a href="#" onclick="subChoc('chocQnty_52','totale_52',79,chocArray,0,'plus',52,ajaxArr);return false;">+</a></td>
  82. <td>Les 365 pensées et ses 12 stylos</td>
  83. <td class="price">79 Euros</td>
  84. <td class="price"><span id="totale_52">79</span> Euros</td>
  85. </tr>
  86.  
  87. <tr><td class="t"></td><td class="t">Montant total pour <em>LES 365 PENSEES</em></td><td class="t"></td><td class="t"><span id="gr_totale">79</span> Euros</td></tr>
  88. </table>
  89.  
  90.         <input type="hidden" id="quote_values" value=";52~1;" />
  91.         <input type="hidden" id="my_cat" value="2" />
  92.         <input type="button" class="button" value="Annuler" onclick="resetArray(); closeMessage();" />
  93.         <input type="button" class="button" value="Ajouter" onclick="javascript:getAjax('getStatus.php','getStatus_2','text','quote_values','my_cat','',''); resetArray(); closeMessage();" />
  94.         </div>
  95.         <div class="break"></div>
  96.     </form>
  97. </body>
  98. </html>
  99.  
But as I told earlier, when I load this page independently using a browser (IE7 here), I don't get any error, and things seems to work. However, when I call this page from another page, I start getting all the bizzare errors.

Also, in some of the browsers like opera and netscape 8.1 it's told that the following piece of code is having syntax error.

Expand|Select|Wrap|Line Numbers
  1. function goto(page) {
  2.     if(page) {
  3.         location.href = page;
  4.     }
  5. }
  6.  
Thanks for any help guys.
Dec 18 '07 #2
kigoobe
67 New Member
OK friends, update time, just incase if someone else reaches this page googling, facing a similar situation ...

As it stands now, I have been able to debug the Safari 3 issues by removing

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml"> 
  3. <head>
  4.  
from the top and the following from the bottom
Expand|Select|Wrap|Line Numbers
  1. </body>
  2. </html>
  3.  
as I found in the example code of modal message, he hasn't put these in his examples. Further, he has saved the popup page as .inc, whereas I've saved them as .php ... hope that's not another reason here.

Update 2

Removing the JS codes, taking the function to the external JS file and the array declaration to the parent page, this is now working in IE7, IE6, Safari 3 and Netscape 9. Netscape 8 is still not working, probably because I have installed Netscape 9 over netscape 8 thereby destroying some of Netscape 8's functionality, or probaby simply netscape 8 is not upto the mark. Opera is not working as well, probably this is an opera bug. Anyway, I am moderately happy if my sites work on IE6, IE7 and FF, and Safari, as I am covering most of the users that way.

If someone can point me out why this is not working, it will be good. Else, here I stop my updates, unless I found a workaround for the Opera.

Here is what Opera's error console is telling, just in case some noble soul wants to have a look.

Expand|Select|Wrap|Line Numbers
  1. JavaScript - http://www.example.com/parent.php
  2. Inline script compilation
  3. Syntax error while loading: line 180 of linked script at http://www.example.com/js/kajax.js : 
  4. function goto(page) {
  5. --------------^
  6. JavaScript - http://www.example.com/parent.php
  7. Event thread: load
  8. Error:
  9. name: ReferenceError
  10. message: Statement on line 1: Reference to undefined variable: subChoc
  11. Backtrace:
  12.   Line 1 of  script 
  13.     subChoc("chocQnty_52", "totale_52", 79, chocArray, 0, "", 52, ajaxArr);
  14.   At unknown location
  15.     [statement source code not available]
  16.  
  17. JavaScript - http://www.example.com/parent.php
  18. Event thread: click
  19. Error:
  20. name: ReferenceError
  21. message: Statement on line 1: Reference to undefined variable: subChoc
  22. Backtrace:
  23.   Line 1 of  script 
  24.     subChoc("chocQnty_52", "totale_52", 79, chocArray, 0, "plus", 52, ajaxArr);
  25. return false;
  26.   At unknown location
  27.     [statement source code not available]
  28.  
It's giving two errors, one telling that it's not finding subChoc function what's now located at kajax.js, unless this is a caching issue. And for the other function, I am unable to find out what the problem is.

Expand|Select|Wrap|Line Numbers
  1. function goto(page) {
  2.     if(page) {
  3.         location.href = page;
  4.     }
  5. }
  6.  
Dec 19 '07 #3
gits
5,390 Recognized Expert Moderator Expert
hi ...

why do you use the img's onload? try to use the onload of the body ... even the script that directly follows the body could be started in that onload ... during page load document.getEle mentById() will always fail ... and return null ... after the page is loaded, it will work as expected and return the nodes properly ...

kind regards
Dec 19 '07 #4
kigoobe
67 New Member
hi ...

why do you use the img's onload? try to use the onload of the body ... even the script that directly follows the body could be started in that onload ... during page load document.getEle mentById() will always fail ... and return null ... after the page is loaded, it will work as expected and return the nodes properly ...

kind regards
Hmmm ... thanks Gits. Actually, I am using img onload in a few instances as variables that I'm passing on that onload are not always created at the top of the page, so I needed a way to call hte onload function at different places of a page. What's the solution then?

Thanks for your reply, btw. :)
Dec 19 '07 #5
gits
5,390 Recognized Expert Moderator Expert
... wait .. i think i don't really get it ... onload is an event that is fired when a specific node is loaded and ready to use by js-dom-methods ... the documents onload itself, that we assign to the body is the one where you have the page really and reliably ready ... i cannot think of a scenario where it couldn't be used ... and has to be replaced with other onload events?
Dec 19 '07 #6
gits
5,390 Recognized Expert Moderator Expert
as far as i know ... when you use an onload of a specific node in the document ... you cannot rely on that the document is already fully loaded ... so you don't have the dom ready to use in all cases ...
Dec 19 '07 #7
kigoobe
67 New Member
Hmmm ... you mean that whatever is the scenario, adding onload with the body tag is the best way to go ...

I've pages where I need to call a function near the end of a page, for example. What do you think would be the best way to call a function in such a scenario? I thought calling the function to an image onload event could be easiest, but as you told, that may not be the best solution. :(
Dec 19 '07 #8
gits
5,390 Recognized Expert Moderator Expert
hi ...

what do you mean with 'to call at the end of the page'? ... again: a page is loaded by the browser ... and it is parsed from top to the bottom. all ressources that are referred by a src-attrib are requested async and when everything is ready the documents onload-event is fired. so that IS semantically the 'end' of the page (its like a callback in an ajax-request ... called when the response is ready to use) ... you should always start js-processing here ... not in the html-code itself, even if you could do that ... you shouldn't :)

simply write a function that calls the things you want and call that function in the onload ...

kind regards
Dec 19 '07 #9
kigoobe
67 New Member
Hi Gits

Thanks for your reply. Sorry for the delayed reply (christmass obligations ..., was out of the town :()

Actually, by later / end of the page what I meant was, I was needing to call javascript somewhere down the page, with variables that has been achieved by now.

Consider this example -

Expand|Select|Wrap|Line Numbers
  1. <?if (isset($result)) {
  2.     $countNo = 0;
  3.     foreach ($result as $rexy) {
  4.         $cid = $rexy['user_index'];
  5.         $cprix = $rexy['prix'];
  6.         $ref = $rexy['type'];
  7.         $cat = $rexy['cat'];
  8.         ?>
  9.         <script type="text/javascript">        
  10.         <!--
  11.         var inter_<?=$cid?> = document.getElementById('chocQnty_<?=$cid?>');
  12.         if (inter_<?=$cid?> && inter_<?=$cid?>.value) {
  13.             var cqnty_<?=$cid?> = inter_<?=$cid?>.value;
  14.         } else {
  15.             var cqnty_<?=$cid?> = 0;
  16.         }                        
  17.         chocArray[<?=$countNo?>] = cqnty_<?=$cid?> + "~" + <?=$cprix?>;
  18.         ajaxArr[<?=$countNo?>] = <?=$cid?> + "~" + cqnty_<?=$cid?>;
  19.         subChoc('chocQnty_<?=$cid?>','totale_<?=$cid?>',<?=$cprix?>,chocArray,<?=$countNo?>,"",<?=$cid?>,ajaxArr);
  20.     //-->        
  21.     </script>
  22.     <?    $countNo ++;
  23. }
  24. }?>
Here I am calling javascript with variable values that I am achieving from the loop. However, here I have changed the onload event, as I have learned since then that I can call javascript functions (subChoc here) without any event actually, and directly inside a <script> tag.

I have solved most of the issues as well, following your suggestions, and moving javascript functions to an external file.

However, here is one thing. The page that holds the above code opens as popup as dhtmlgoodies's modal message tool (ajax). This page has no head / body etc, just row code with php echos to print different things in the popup.

However, though FF works properly here, IE doesn't take into account the javascript things. In fact, I can't even get an alert at the very beginning (just after <script>, not even a simple alert like alert('hi there');

If I call the popup directly from the browser, IE can read the javascript, but however, as a popup, it doesn't seem to read the javascript.

Again, if I do
Expand|Select|Wrap|Line Numbers
  1. echo '<img src="img/spacer.gif" width="1" height="1" onload="alert(\'hi again\');" />'."\r\n"; 
it works, even in IE. So it seems that I need a way to put the whole javascript thing with an event. Hmmm ...

Probably I would love to know how can I declare a javascript mixed variable, as in -
Expand|Select|Wrap|Line Numbers
  1. function onloadEvents(cid,countNo,cprix) {
  2.    var inter_+cid = document.getElementById('chocQnty_'+cid);
  3. }
Here, cid is getting a value from the function argument, and I am adding a prefix to this called inter at the beginning to get a combined variable name. Things like var 'inter_'+cid doesn't work ... Idea would be to get resulting variables like inter_36, inter_64, inter_99, etc.
Dec 25 '07 #10

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

Similar topics

5
14630
by: NanQuan | last post by:
I'm hoping someone can help me solve this error since I am at a total loss here. Usually I don't bother posting on any forums or groups on the internet and prefer to solve stuff myself but this is a total mistery. I have a function inside an ASP page as a result of which I get the following error message: Microsoft VBScript compilation error '800a03ea'
6
19259
by: Dan Roberts | last post by:
I am running some off-the-shelf software that is written in ASP, which uses JScript to generate dynamic content within HTML forms. There are several ASP pages which are partially rendering to IE, but stop midway through with an error embeded in the page: "Microsoft JScript runtime error '800a138f' 'undefined' is null or not an object". The software package has a large install base with no other customer having this problem. I also have...
5
2261
by: damian birchler | last post by:
What's wrong about this: 22: static void (*)(void) instruction_table = { jnz, halt, mv, add, mul, mv_reg, add_reg,
7
2189
by: Ray Dillinger | last post by:
Hi. I'm having a problem and I really want to understand it. Here's the situation: I have an array of pointers, and each pointer is the head of a linked list of structs. The structs are typedef'd to have the type name 'event.' It's a simple open hash table used to implement events in a game. So, I have a routine that returns the address of one of the pointers in the array, or returns NULL for a key out of range (meaning no bucket for...
2
1813
by: RogerInHawaii | last post by:
I would like to pass an array by reference to a function so that I can modify the contents of the array and effectively "return" that array to the caller. I tried doing this: function MyFunction(&$MyArray) { MyArray = "First"; MyArray = "Second"; }
12
5682
by: Franz Hose | last post by:
the following program, when compiled with gcc and '-std=c99', gcc says test.c:6: error: jump into scope of identifier with variably modified type that is, it does not even compile. lcc-win32, on the other hand, reports Warning test.c: 7 unreachable code
5
2192
by: Joshr35 | last post by:
I keep getting this same error on my store front page login area. Parse error: syntax error, unexpected '{' Here's the actuall php script: <?php if ( (!strstr($_SERVER,'login.php')) and (!strstr($_SERVER,'create_account.php'))
1
2849
by: Mary meer | last post by:
i am trying to switch array value but i get this error message: Undefined offset 2 $at=array( array('Title:','title',2,10), array('First Name:','fname',2,10 ), i have foreach loop foreach($at as $v){ switch ($v){
5
1943
by: Adam Pelling | last post by:
I'm getting this error Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/neblncbt/public_html/forum/includes/acp/acp_board.php on line 69 Here is the acp_board.php file <?php /** * * @package acp
0
9673
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10449
Oralloy
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...
0
10217
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10168
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,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9047
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6785
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();...
0
5568
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2924
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.