473,789 Members | 2,544 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting Error: Object expected

In my HTML I have,
<input type="button" class="cartonsu mkey" value="Sum Cartons"
onclick="sumup( this);" />

In an external file that is called in Head area, I have,

function sumup( o ) {

var totoalCartons = 0;
var row = document.getEle mentById( 'oceanDeliverie s' ).rows;
var i = row.length - 1;
var lastrow = row[i];

while(i--) {
totalCartons += parseInt( row[i].cells[8].innerText ) || 0;
}

if( lastrow.cells[8] ) {
lastrow.cells[8].firstChild.nod eValue = totalCartons;
}

o.disabled = true;
}

I am getting Error: Object expected.

Please help!

Thanks,
Yasaswi

Feb 28 '07 #1
8 4690
On Feb 28, 10:52 pm, "ipy2006" <ipyasa...@gmai l.comwrote:
In my HTML I have,
<input type="button" class="cartonsu mkey" value="Sum Cartons"
onclick="sumup( this);" />

In an external file that is called in Head area, I have,

function sumup( o ) {

var totoalCartons = 0;
var row = document.getEle mentById( 'oceanDeliverie s' ).rows;
var i = row.length - 1;
var lastrow = row[i];

while(i--) {
totalCartons += parseInt( row[i].cells[8].innerText ) || 0;
}

if( lastrow.cells[8] ) {
lastrow.cells[8].firstChild.nod eValue = totalCartons;
}

o.disabled = true;

}

I am getting Error: Object expected.

Please help!

Thanks,
Yasaswi
Is it possible that you simply have a syntax error, in the first line
of the function, where you wrote totOal instead of total? Try also not
passing the "this" object to the function, because it's automatically
available in the function if it's an event handler. That is, don't
pass "this" in the function call, don't declare "o" as function
argument, and use "this" in the function directly instead of "o". Use
firefox, too, so it can tell you in which line the error happens
(hint: use Error console in the Tools menu of Firefox).

Feb 28 '07 #2
On Mar 1, 7:52 am, "ipy2006" <ipyasa...@gmai l.comwrote:
In my HTML I have,
<input type="button" class="cartonsu mkey" value="Sum Cartons"
onclick="sumup( this);" />

In an external file that is called in Head area, I have,

function sumup( o ) {

var totoalCartons = 0;
Did you mean: totalCartons ?
var row = document.getEle mentById( 'oceanDeliverie s' ).rows;
var i = row.length - 1;
var lastrow = row[i];

while(i--) {
Since i is already the number of rows, this will skip the last row
(which I guess you want it to do).
totalCartons += parseInt( row[i].cells[8].innerText ) || 0;
innerText is an IE proprietary property that is not available in some
browsers, the W3C equivalent is textContent. You might consider using
the cell's firstChild.data or innerHTML property.

var cell = row[i].cells[8];
totalCartons += (cell.firstChil d && +cell.firstChil d.data);

or

totalCartons += +row[i].cells[8].innerHTML;

}

if( lastrow.cells[8] ) {
lastrow.cells[8].firstChild.nod eValue = totalCartons;
}

o.disabled = true;
What do you expect o is? What is it actually? Use an alert placed
before this line to find out:

alert( typeof o + '\n' + o.tagName);
>
}

I am getting Error: Object expected.
At which line?

--
Rob

Feb 28 '07 #3
On Feb 28, 6:38 pm, "RobG" <r...@iinet.net .auwrote:
On Mar 1, 7:52 am, "ipy2006" <ipyasa...@gmai l.comwrote:
In my HTML I have,
<input type="button" class="cartonsu mkey" value="Sum Cartons"
onclick="sumup( this);" />
In an external file that is called in Head area, I have,
function sumup( o ) {
var totoalCartons = 0;

Did you mean: totalCartons ?
var row = document.getEle mentById( 'oceanDeliverie s' ).rows;
var i = row.length - 1;
var lastrow = row[i];
while(i--) {

Since i is already the number of rows, this will skip the last row
(which I guess you want it to do).
totalCartons += parseInt( row[i].cells[8].innerText ) || 0;

innerText is an IE proprietary property that is not available in some
browsers, the W3C equivalent is textContent. You might consider using
the cell's firstChild.data or innerHTML property.

var cell = row[i].cells[8];
totalCartons += (cell.firstChil d && +cell.firstChil d.data);

or

totalCartons += +row[i].cells[8].innerHTML;
}
if( lastrow.cells[8] ) {
lastrow.cells[8].firstChild.nod eValue = totalCartons;
}
o.disabled = true;

What do you expect o is? What is it actually? Use an alert placed
before this line to find out:

alert( typeof o + '\n' + o.tagName);
}
I am getting Error: Object expected.

At which line?

--
Rob

Thank you Rob and Darko. The totalCartons typo was the problem.
Thanks a lot.
Yip

Mar 1 '07 #4
ipy2006 wrote:

[snip]
>
Thank you Rob and Darko. The totalCartons typo was the problem.
Thanks a lot.
Yip
No, that is not your own problem, read Rob's post carefully.
Mick
Mar 4 '07 #5
RobG wrote:
totalCartons += (cell.firstChil d && +cell.firstChil d.data);

I don't get this, Rob, surely the rh expression is Boolean, no?

Mick
Mar 4 '07 #6
On Mar 4, 12:30 pm, Michael White <m...@mickweb.c omwrote:
RobG wrote:

totalCartons += (cell.firstChil d && +cell.firstChil d.data);

I don't get this, Rob, surely the rh expression is Boolean, no?
No.

It is a shortcut way of checking that cell has a firstChild property
that doesn't evaluate to false (i.e. since it's a DOM object, that it
has a firstChild) before attempting to access one of cell.firstChild 's
properties (and then converting it to a number).

The && operator is also called the "guard" operator. In an expression
like:

a && b && c

The expressions are evaluated from left to right until either the
result of one of them evaluates to false or there are no more
statements. The value of the last statement evaluated is returned, so
either the first that evaluates to false or the last one.

The "+" operator is used as a unary operator to convert the string
result of cell.firstChild .data to a number, hence:

cell.firstChild .data ==String
+cell.firstChil d.data ==Number

it is short and faster than the (more or less) eqivalent:

parseInt(cell.f irstChild.data, 10)

or

Number(cell.fir stChild.data)
--
Rob

Mar 4 '07 #7
Michael White wrote:
RobG wrote:

totalCartons += (cell.firstChil d && +cell.firstChil d.data);

I don't get this, Rob, surely the rh expression is Boolean, no?
With a logical expression in javascript the values of the sub-expressions
are type-converted to boolean in order to determine the result of the
whole expression (up to the point where the result can be certain (so in
this expression only the - cell.firstChild - is type converted to
boolean)) but the value of the whole expression is the value of the
significant sub-expression (not the type-converted to boolean equivalent
of that value).

Richard.

Mar 4 '07 #8
Richard Cornford wrote:
Michael White wrote:
>RobG wrote:

totalCartons += (cell.firstChil d && +cell.firstChil d.data);

I don't get this, Rob, surely the rh expression is Boolean, no?


With a logical expression in javascript the values of the
sub-expressions are type-converted to boolean in order to determine the
result of the whole expression (up to the point where the result can be
certain (so in this expression only the - cell.firstChild - is type
converted to boolean)) but the value of the whole expression is the
value of the significant sub-expression (not the type-converted to
boolean equivalent of that value).
Thanks Rob and Richard.
Mick
Mar 6 '07 #9

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

Similar topics

5
2724
by: Rick | last post by:
I wrote the following code as part of a page where users can reorder a list of items by highlighting an item in a list box and clicking an "up" or "down" button to move the items around. The code below is for the up and down buttons along with a reset button (which reloads the list as it was originally) and a change button which applies the changes. In Explorer and Safari for Mac, this code works flawlessly. When I tested on Explorer in...
1
10316
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error CS1002: ; expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(7,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(9,2): error CS0116: A namespace does not...
1
2295
by: Franko | last post by:
I get the following error. Please help c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,38): error CS1001: Identifier expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(6,52): error CS1002: ; expected c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(7,19): error CS1519: Invalid token '(' in class, struct, or interface member declaration c:\inetpub\wwwroot\WebApplication1\WebForm2.aspx(9,2): error CS0116: A namespace does not...
2
1796
by: khalaskapil | last post by:
i m getting Object Expected error, i m using master page & i m call javascript function in child age: this is my child page where i m calling javascript functionNewCal(), <div> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <%--<asp:TextBox ID="txtDOB" runat="Server" Text=""></asp:TextBox>--%> <input type="text" id="txtDOB" value="" /> ...
6
4420
by: =?Utf-8?B?dGhsMTAwMA==?= | last post by:
Hi NG, i need to list the logonHours for a specific user. I'm trying to convert code from vbscript (is working) to vb.net, but the vb.net code does not work. Here are the code listings: 1: vbscript:
1
3918
by: JOJO123 | last post by:
I got here in search of an answer to this Javascrpt question. I upgraded jave on XP Ie 7, acrobat 5.1 and suddenly can't open any pdf files on web sites using IE. I see u guys all say, this is a Javscript issue. but how do we, mere mortals who know nothing of anything about Java, scripts, etc, fix this? Is there a programm, does MS have any fix? is there any tweak like in the Registry, or whatever, how do I access anyihint java without in IE 7...
6
5331
by: Lawrence Spector | last post by:
I ran into a problem using g++. Visual Studio 2005 never complained about this, but with g++ I ran into this error. I can't figure out if I've done something wrong or if this is a compiler bug. Here's a very simple example which should illustrate what I'm doing. #include <iostream> template <class T> class TestBase {
1
1622
by: Rahul | last post by:
I am getting following error: 1) For a xml file "Request.xml" we created a schema "Request.xsd". 2) With the help of xsd.exe we got the C# file Request.cs. 3) We tried to send the object of Request.cs to a webservice method SaveRequest(Request req). 4) Scenario is like same Request.cs is referenced by both server and
2
2463
by: vijayrvs | last post by:
SearchCrawler.java The program search crawler used to search the files from the website. From the following program i got 7 compiler error. can any body clarify it and provide me solution. import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import java.util.*;
0
9663
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
9511
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
10404
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
10195
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
10136
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
9979
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...
1
7525
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
6765
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
5415
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 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.