File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes Object Required error in Javascript. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Object Required error in Javascript." Watch "Object Required error in Javascript." New topic

Object Required error in Javascript.

Anil dhingra

Joined: Oct 01, 2009
Posts: 8
Hi All,
My code looks like below:

function OnHTMLTable1_ClickLink ( ) {

var TableDiv = document.getElementById("HTMLTable1");
var oRows = document.getElementById("HTMLTable1").getElementsByTagName('tr');
var iRowCount = oRows.length;

for(k=1; k<=iRowCount; k++)
if(document.getElementById("list"+o+k).selectedIndex == 0)

document.getElementById("list"+o+k).selectedIndex = 1;
document.getElementById("list"+o+k).options[1].style.backgroundColor = "green";

when I am trying to run this code it opens a new browser page and throwing a error "Object Required".I think it is not finding the object "HTMLTable1" and reading it as a null value due to which throwing this error.Please suggest me the way to handle this error in javascript.

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63858

Is there an element with an id of HTMLTable1 in the DOM? Don;t you think this is important information to include in your post?

[Asking smart questions] [About Bear] [Books by Bear]
Anil dhingra

Joined: Oct 01, 2009
Posts: 8
HTMLTable1 is the object which i am paasing to get the no. of rows in the HTML table.That row count is getting used in the code further for coloring the cells.Please let me know if you require any further input regarding this.

I agree. Here's the link:
subject: Object Required error in Javascript.
It's not a secret anymore!