Question

Javascript Problem in IE: object doesn't support this property or method

Asked by: khyer123

I am working on a form that allows people to sign up people onto a team. The form includes a button that allows the user to add people to his roster. When the user clicks the button, a javascript function adds fields to the form. It works great in firefox, but gives me an "object doesn't support this property or method" error in IE, and won't work in Chrome.

Does anyone have any idea as to why it might work only for FF and not for IE/Chrome?

//this is the function 
 
function addToRoster(){
	//find out how many people are already on the roster
	var table = document.getElementById('roster');
	var rows = roster.getElementsByTagName('tr');
	var count = rows.length - 2; //two rows are automatically included: headers and button to add players
	if(count == document.getElementById('ppt').value)
	{
		alert('You have already added the maximum number of players to your roster.');
		return;
	}
	var lastRow = table.rows.length;
	var row = table.insertRow(lastRow);
	
	//name cell
	var nameCell = row.insertCell(0);
	var element = document.createElement('input');
	element.type = 'text';
	element.name = 'name';
	element.size = 30;
	nameCell.appendChild(element);
	
	//rin cell
	var rinCell = row.insertCell(1);
	element = document.createElement('input');
	element.type = 'text';
	element.name = 'rin';
	element.size = 12;
	rinCell.appendChild(element);
	
	
		//email cell
	var emailCell = row.insertCell(2);
	element = document.createElement('input');
	element.type = 'text';
	element.name = 'email';
	element.size = 12;
	emailCell.appendChild(element);
}
 
//this is the button 
<input type="button" value="Add Player" onclick="addToRoster()" />
                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-11 at 20:46:42ID24803590
Tags

javascript

,

ie

,

ajax

Topics

JScript

,

Asynchronous Javascript and XML (AJAX)

Participating Experts
4
Points
500
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Javascript and Firefox
    I have some Javascript that works fine in IE7 but not in Firefox 2.0. I have checked the error console and only assume that FF does not like the same syntax that IE7 does. This is starting to drive me crazy: Here is the JS... t simply gets fed an ID that is used to evaluate...
  2. Google Chrome - Javascript Problem
    Hello Experts, Having a little trouble with Google Chrome and some bit of my JavaScript. The snippet below woks fine in IE 7 but not in Chrome. Could someone please advise why it wouldn't? And a solution to the problem. All it does is hide a green tick when the user selects...
  3. Javascript not firing in CHROME
    hi I have a dropdown that fires an onchange event. The javascript event bascially show'hide a label depending on the selection. When i test it on IE 7, Chrome, FF 3 it works correctly. Now i added a RequiredFieldValidator on the dropdown. When i tested again. IE 7 and FF ...
  4. My javascript works in IE and Firefox, but not Chrome.
    I have the following javascript code in a form. It looks at a value of a field in the form and rewrites the links to append the session tab at the end of the url. This works like it should in IE and Firefox without any problems. Chrome, however; does not work, nor is it gi...
  5. JavaScript breaking on IE but running fine on FF and Chrome
    I have some simple JavaScript code that is failing on IE7 and IE8 but works fine on FF and Chrome. The main page, Index.html below, creates an array called "order" and declares a routine to pass the array to a child window. A single button opens up a child window...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: zanus123Posted on 2009-10-11 at 21:01:19ID: 25548579

what does your full HTML look like

and does the error give a line number

 

by: kadabaPosted on 2009-10-11 at 21:19:42ID: 25548622

I tested this as a stand alone and it worked fine... in all the browsers you mentioned...

<html>	
	<head>
		<script type="text/javascript">
		function addToRoster()
		{
				//find out how many people are already on the roster
				var table = document.getElementById('roster');
				var rows = roster.getElementsByTagName('tr');
				var count = rows.length - 2; //two rows are automatically included: headers and button to add players
				if(count == 4)
				{
						alert('You have already added the maximum number of players to your roster.');
						return;
				}
				var lastRow = table.rows.length;
				var row = table.insertRow(lastRow);
				
				//name cell
				var nameCell = row.insertCell(0);
				var element = document.createElement('input');
				element.type = 'text';
				element.name = 'name';
				element.size = 30;
				nameCell.appendChild(element);
				
				//rin cell
				var rinCell = row.insertCell(1);
				element = document.createElement('input');
				element.type = 'text';
				element.name = 'rin';
				element.size = 12;
				rinCell.appendChild(element);
				
				
						//email cell
				var emailCell = row.insertCell(2);
				element = document.createElement('input');
				element.type = 'text';
				element.name = 'email';
				element.size = 12;
				emailCell.appendChild(element);
		}
		</script>
	</head>
	<body>
		<table id="roster" border="1">
			<tr>
				<td>
					This is the header 1
				</td>
				<td>
					This is the header 2
				</td>
				<td>
					This is the header 3
				</td>
			</tr>
			
			<tr>
				<td colspan="3">
					<input type="button" value="Add Player" onclick="addToRoster()" />
				</td>
			</tr>
		</table>
	</body>
</html>
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:

Select allOpen in new window

 

by: khyer123Posted on 2009-10-11 at 22:04:42ID: 25548707

Here is the full source shown in IE. It's assembled from several .php files.

<html>
<head>
<title>Sports and Recreation Management System</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link rel="stylesheet" type="text/css" href="css/lightbox.css">
<script src="scripts/prototype.js" type="text/javascript"></script>
<script src="scripts/scriptaculous.js" type="text/javascript"></script>
<script src="scripts/lightbox.js" type="text/javascript"></script>
<script src="scripts/functions.js" type="text/javascript"></script>
</script>
</head>
<body>
<div id="main" style="min-height:1500px;" >
	<div id="header">
	
	</div>
	<div id="bar_top">
		<p>Welcome,  (<a href="actions.php?action=logout">Logout)</a> </p>		
	</div>
	<div id="sidemenu">
		<ul>
	<li class="title">Main Menu</li>
	<li><a href="home.php?league=redhawk">Home</a></li><li><a href="sports_info.php?league=redhawk">Sports Information</a></li><li><a href="sports_rules.php?league=redhawk">Sports Rules</a></li><li><a href="policies.php?league=redhawk">Policies</a></li><li><a href="forms.php?league=redhawk">Forms</a></li><li><a href="contact.php?league=redhawk">Contact Information</a></li></ul><ul>
	<li class="title">Sign-Up/Create Team</li>
	<li><a href="newteam.php?league=redhawk">Create New Team</a></li>    
					  <li><a href="freeagent.php?league=redhawk">Free Agent Signup</a></li>
					  <li><a href="signin.php?league=redhawk">Captain Sign-in (exiting teams)</a></li></ul>				<ul>
			<li class="title">Admin Menu</li>
			<li><a href="settings.php">Manage Settings</a></li>
			<li><a href="games.php">Manage Games</a></li>
			<li><a href="contact_info.php">View Contact Info</a></li>
		</ul>	
		
				
	</div>
	<div id="content">
		<h1></h1>
					<h1>Create a New Team</h1>
		<a href="profile.php" class="lbOn"><h2>IMPORANT: Update Profile</h2></a>
		<br>
		<form name="roster" action="actions.php?action=addroster&league=redhawk" onSubmit="return verifyRoster()" method="POST">
		<select name="sport" id="sport" onchange="showInfo()" width="500"  style="width: 500px;">
			<option value="0">SELECT SPORT</option>
			<option value="3">Soccer</option> 		</select>
		<br><br>
 
		<div id="sport_info" class="infodiv" style="display:none;background-color:#FF9B9B">
			Maximum Teams: <input class="noborder" type="text" id="maxteams" />
			<br>
			New Team Signups Available:  <input class="noborder" type="text" id="avail" />
			<br>
			Players Per Team: <input class="noborder" type="text" id="ppt" />
		</div>
		<br>
		<div id="waitlist_notice" class="infodiv" style="display:none;">
			<center><b>This sport is currently full. Should you decide to continue to sign up, you will be added to the waitlist.</b></center>
		</div>
		<br><br>
		<div id="signup_form" style="width:600px;display:none;">
		<table width="550px">
	<col width="50%">
	<col width="50%">
	<thead>
		<th colspan="2"><center>Intramural Sports Signup</center></th>
	</thead>
	<tbody>
		<tr>
			<td>Selected Sport</td>
			<td><input type="text" name="sport_name" id="sport_name" READONLY/></td>
		</tr>
		<tr>
			<td>Team Name</td>
			<td><input type="text" name="team_name" id="team_name" /></td>
		</tr>
		<tr>
			<td>Captain Name</td>
			<td><input type="text" name="captain_name" /></td>
		</tr>
		<tr>
			<td>Captain RIN</td>
			<td><input type="text" name="captain_rin" /></td>
		</tr>
		<tr>
			<td>Captain Phone #</td>
			<td><input type="text" name="captian_phone" /></td>
		</tr>
		<tr>
			<td>Captain E-mail</td>
			<td><input type="text" name="captain_email" /></td>
		</tr>
		<tr>
			<td>Co-Captain Name</td>
			<td><input type="text" name="cocaptain_name" /></td>
		</tr>
		<tr>
			<td>Co-Captain RIN</td>
			<td><input type="text" name="cocaptain_rin" /></td>
		</tr>
		<tr>
			<td>Co-Captain Phone #</td>
			<td><input type="text" name="cocaptain_phone" /></td>
		</tr>
		<tr>
			<td>Co-Captain Email</td>
			<td><input type="text" name="cocaptain_email" /></td>
		</tr>
	</tbody>
</table>
<table width="550px" id="roster">
	<col width="50%">
	<col width="25%">
	<col width="25%">
	<thead>
		<th colspan="4"><center>Team Roster</center></th>
	</thead>
	<tbody>
		<tr>
			<td colspan="4"><input type="button" value="Add Player" onclick="addToRoster()" /> Note: You can add free agents to your roster later</td>
		</tr>
		<tr>
			<td>Name</td>
			<td>RIN</td>
			<td>E-mail</td>
		</tr>
	</tbody>
</table>
<table width="550px" id="times">
	<thead>
		<th><center>Available Times to Play</center>
	</thead>
	<tbody>
		<tr>
		
		</tr>
	</tbody>
</table>
<table width="550px">
	<tr>
		<td><input type="submit" value="Submit Roster"></td>
	</tr>
</table>
 
		</div>
		</form>
		
		
	</div>
	
 
</div>
 
 
 
 
</body>
 
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:

Select allOpen in new window

 

by: khyer123Posted on 2009-10-11 at 22:06:52ID: 25548709

Oh, and it gives the error on line 64, char 2

 

by: xxli79Posted on 2009-10-11 at 22:09:30ID: 25548713

You'd better attach the full HTML and the error message.
But I guess the error was caused by line 6, and recommend write it like this:

var rows = table.rows;

                                              
1:

Select allOpen in new window

 

by: kadabaPosted on 2009-10-11 at 22:22:59ID: 25548739

>> Oh, and it gives the error on line 64, char 2

right click in the browser and view the page source see whats there at line 64

 

by: khyer123Posted on 2009-10-11 at 22:48:22ID: 25548797

The line 64 looks like it refers to my javascript file.

I changed the code to:

var table = document.getElementById('roster');
var lastRow = table.rows.length;
var row = table.insertRow(lastRow);

Because I didn't need the count variable, and now it tells me "rows.length is null or not an object".

 

by: pramodkrjsrPosted on 2009-10-11 at 22:50:03ID: 25548801

@kadaba, you have not used field - "ppt",

@khyer123,
Below is working fine with your input box - "ppt" in FF, IE, Chrome

<html>
<head>
    <script type="text/javascript">
 
        function addToRoster() {
            //find out how many people are already on the roster
            var table = document.getElementById('roster');
            var rows = roster.getElementsByTagName('tr');
            var count = rows.length - 2; //two rows are automatically included: headers and button to add players
            if (count == document.getElementById('ppt').value)
            {
                alert('You have already added the maximum number of players to your roster.');
                return;
            }
            var lastRow = table.rows.length;
            var row = table.insertRow(lastRow);
 
            //name cell
            var nameCell = row.insertCell(0);
            var element = document.createElement('input');
            element.type = 'text';
            element.name = 'name';
            element.size = 30;
            nameCell.appendChild(element);
 
            //rin cell
            var rinCell = row.insertCell(1);
            element = document.createElement('input');
            element.type = 'text';
            element.name = 'rin';
            element.size = 12;
            rinCell.appendChild(element);
 
 
            //email cell
            var emailCell = row.insertCell(2);
            element = document.createElement('input');
            element.type = 'text';
            element.name = 'email';
            element.size = 12;
            emailCell.appendChild(element);
        }
    </script>
 
</head>
<body>
 
Players Per Team: <input type="text" id="ppt">
<table id="roster" border="1">
    <tr>
        <td colspan="3"><input type="button" value="Add Player" onclick="addToRoster()"/></td>
    </tr>
    <tr>
        <th>Name</th><th>Rin</th><th>Email</th>
    </tr>
    <tr id="tr"></tr>
</table>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:

Select allOpen in new window

 

by: khyer123Posted on 2009-10-11 at 22:57:44ID: 25548822

@pramodkrjsr  I had removed the code involving the "ppt" - there is no longer a restriction on players per team. But what is with the <tr id="tr"></tr> on line 56 of the code you submitted?

 

by: pramodkrjsrPosted on 2009-10-11 at 23:00:51ID: 25548829

@khyer123,
Earlier i was trying using getElementById('tr')

Now you may ignore that line.

 

by: xxli79Posted on 2009-10-11 at 23:02:34ID: 25548833

There are must more than one "roster" elements in the html, like the code below, you'd better check it.

<xxx id="roster" ....>
...
<table id="roster">....

 

by: khyer123Posted on 2009-10-11 at 23:06:30ID: 31639912

Yep, that was it... the form ID was roster AND the table ID was roster. It all works now. Thanks for your help

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...