aspose file tools*
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Object Required error in Javascript." Watch "Object Required error in Javascript." New topic
Author

Object Required error in Javascript.

Anil dhingra
Greenhorn

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.

Thanks,
Anil
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61760
    
  67

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] [Bear's FrontMan] [About Bear] [Books by Bear]
Anil dhingra
Greenhorn

Joined: Oct 01, 2009
Posts: 8
Hi,
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.

Thanks.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Object Required error in Javascript.