473,788 Members | 3,030 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

divs, innerHTML and unknown runtime errors

Getting an "unknown runtime error code 0" in IE6 on the last two lines
of the function below. Works fine in Firefox 1.5, I can't figure out
what IE is complaining about. Both "subtotal" and "totaldiv" are divs
with the respective ids, both contain only "$0" initially.

function updateprice(pac kageName) {
document.orderF orm.Subpackage. value = packageName;
var tempsub =
getSelectedRadi oValue(document .orderForm.subs cription);
var sub1 = tempsub.split(" :");
var suba = sub1[0];
var subb = sub1[1];
totalprice = document.orderF orm.seats.value * suba;
shippingprice = document.orderF orm.shipping.va lue
document.getEle mentById("total ").value = (parseInt(total price) +
parseInt(shippi ngprice));
document.orderF orm.subtotal.va lue = totalprice;
document.getEle mentById('subto tal').innerHTML = '$' + totalprice;
document.getEle mentById("total div").innerHTM L = "$" +
(parseInt(total price) + parseInt(shippi ngprice))
}

The named "subtotal" child of orderForm is getting set correctly, so
it's something about setting the innerHTML in the divs. Looked through
the groups/googled, most of what I found referenced altering table
structure, which I'm not doing.

Any thoughts?

Feb 15 '06 #1
10 2191
Switch to double quotes on referencing subtotal and the string, see if
that helps

Feb 15 '06 #2

rwalrus wrote:
var subb = sub1[1];
totalprice = document.orderF orm.seats.value * suba;


You multiply two string values. Convert them to integers or floats
before multiplication.
(parseInt, parseFloat)

totalprice = parseInt(docume nt.orderForm.se ats.value) * parseInt(suba);

Feb 16 '06 #3

rwalrus wrote:
totalprice = document.orderF orm.seats.value * suba;


You multiply two string values. You should convert it to desired type
with "parseInt" or "parseFloat " functions.
Eg.:
totalprice = parseInt(docume nt.orderForm.se ats.value) * parseInt(suba);

Maybe you problem is here.

Feb 16 '06 #4
marss wrote:
rwalrus wrote:
var subb = sub1[1];
totalprice = document.orderF orm.seats.value * suba;

You multiply two string values. Convert them to integers or floats
before multiplication.
(parseInt, parseFloat)


That is unnecessary, strings are converted to numbers (if they can be)
as a part of the multiplication process. If they can't, the result is
NaN, which is not the error that the OP reported.

totalprice = parseInt(docume nt.orderForm.se ats.value) * parseInt(suba);


parseInt should never be used without a radix, particularly when
processing string input that may contain leading zeros.
--
Rob
Feb 16 '06 #5
UnaCoder wrote:
Switch to double quotes on referencing subtotal and the string, see if
that helps


It shouldn't. Double and single quotes are interchangeable , provided
they are nested correctly. There is no thing in the posted code to
indicate that they aren't (nested correctly).


--
Rob
Feb 16 '06 #6
rwalrus wrote:
Getting an "unknown runtime error code 0" in IE6 on the last two lines
of the function below. Works fine in Firefox 1.5, I can't figure out
what IE is complaining about. Both "subtotal" and "totaldiv" are divs
with the respective ids, both contain only "$0" initially.


You have a form element named 'subtotal' and a div with the same ID. IE
doesn't like that, change one of them.

[...]

--
Rob
Feb 16 '06 #7
VK

rwalrus wrote:
document.orderF orm.subtotal.va lue = totalprice;
document.getEle mentById('subto tal').innerHTML = '$' + totalprice;


.... which suggests that you have a form element and a DIV named
"subtotal" (I guess the same with "total"). You cannot do that in IE,
because it implements a broken namespace schema.

Go through you page (and any others if needed) and make sure that *no
one* ID on the page repeats an ID *or* NAME of a form element. So say
if you have:
<input type="text" name="subtotal" id="subtotalID" >
you cannot use neither "subtotal" nor "subtotalID " anywhere else: nor
for div's, nor for iframe's, nor for nothing.

Correct this and it will work (unless of course you have other errors
in your script :-)

Feb 16 '06 #8
marss wrote:
rwalrus wrote:
var subb = sub1[1];
totalprice = document.orderF orm.seats.value * suba;


You multiply two string values. Convert them to integers or floats
before multiplication.
(parseInt, parseFloat)


As Rob said.

Furthermore, there is only one external numerical type in the corresponding
ECMAScript implementations as yet: `number', an IEEE-754 double-precision
floating-point number value, no matter its string representation (such as
with window.alert()) . In those implementations , unsigned 32-bit Integers
are used internally only. parseInt() and parseFloat() do not convert a
string value to an integer value or a float value, respectively. Both
merely parse a string in a certain way and return the corresponding
`number' value.
PointedEars
Feb 17 '06 #9
VK wrote:
rwalrus wrote:
document.orderF orm.subtotal.va lue = totalprice;
document.getEle mentById('subto tal').innerHTML = '$' + totalprice;


... which suggests that you have a form element and a DIV named
"subtotal" (I guess the same with "total"). You cannot do that in IE,
because it implements a broken namespace schema.

Go through you page (and any others if needed) and make sure that *no
one* ID on the page repeats an ID *or* NAME of a form element. So say
if you have:
<input type="text" name="subtotal" id="subtotalID" >
you cannot use neither "subtotal" nor "subtotalID " anywhere else: nor
for div's, nor for iframe's, nor for nothing.

Correct this and it will work (unless of course you have other errors
in your script :-)


That fixed it. Thanks for the help. Most of the underlying code and
markup I'm trying to maintain is not mine, and pretty hackwork, so a
lot of these bizzare errors keep cropping up. I appreciate the help.

--
Ryan W

Feb 17 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2076
by: gaehn gaehn | last post by:
Here is my problem in a nutshell: a script to model dynamic table extension. It works under Firefox. But IE just aborts, complaining about an "unknown runtime error" in the line with "innerHTML". Why? <html><head></head><body> <script language="javascript"> function extend() { var tb = document.getElementById('thetable').tBodies; var newrow = document.createElement('tr');
16
13347
by: Joel Byrd | last post by:
I am having this ridiculous problem of trying to set the innerHTML of a div node. It works in all other browsers, but internet explorer is giving me an "Unknown runtime error". This is actually in the context of developing an auto-suggest (basically reverse-engineering Google Suggest), but I don't see how any of the other code has anything to do with it. I *pretty sure* that I've narrowed it down to 1 line (the line on which the...
5
3618
by: tlyczko | last post by:
Hello, I've searched on toggling divs and didn't really find what I was looking for, I saved a bunch of different threads. I have a form with several different text boxes for things like dates, numbers, etc. arranged in a table, each row has the same kind of text boxes for data entry (10 rows probably). I want to have a separate section above the form where I can toggle a div containing an appropriate error message to appear after the...
2
4827
by: Jakub Łukomski | last post by:
hi. i've got a problem as follows, to which i can't find a solution to: i've got two divs, which are completely independent of each other (neither is a parent of child of another). they're positioned (either absolutely or relatively) in a way that they overlap each other. when i assign an onmousemove event to them, only one of them catches it. any capturing and/or bubbling is beeing performed by parents of the div that caught the...
7
38027
by: John | last post by:
Hi Everyone, I'm having this extremely annoying problem with Internet Explorer 6, giving me an error message saying "unknown runtime error" whenever I try to alter the contents of a <divelement using innerHTML. Now, I've researched this problem on the web, and found many references to it, but none of them quite addressed my specific situation, and since my experience with JavaScript is limited, I was not able to adapt the solutions I...
11
1563
by: rohitchawla | last post by:
i have problem with innerHTML i get the value of innerHTML of tr and modify the text but when i try to put this text back in innerHTML it says unknown runtime error im trying to append some paramaeter in the onclick url <table bgcolor= "#FFFFFF" width="150" border="0" cellpadding="0" cellspacing="0"> <tr id="xyz"> <td height="150" style="cursor:pointer; cursor: hand;" onClick="popup = window.open...
1
1299
by: maya | last post by:
hi, I need to swap divs.. I know how to do this very well when the divs are positioned absolutely and thus they are "on top of" each other with z-index, etc... but now at work I have to do this w/divs that are not positioned absolutely, they use two very large js files here for it (swapTabs.js and prototype.js.. in case they sound familiar to anyone..) and every time I have a hard time implementing it.. I was wondering if somebody
3
1532
by: useenu | last post by:
Hi all, I am new to this forum and javascript. I am developing a progress bar in javascript. For that I planned to have series of small DIVs in a big DIV. I have written a below function.It is working in IE, but not in Firefox. function createDiv(leftPx, topPx, widthPx, heightPx, divColor) { dv = document.createElement('div'); dv.style.position="absolute"; dv.style.pixelLeft=leftPx; dv.style.pixelTop=topPx;...
0
9655
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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9498
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10363
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
10172
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
10110
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
8993
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 projectplanning, coding, testing, and deploymentwithout 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...
1
7517
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6749
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
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.