/    Sign up×
Community /Pin to ProfileBookmark

error with tbl.tBodies[0].rows.length

hai, i’m new with javascript..

i want to make a dinamic table using javascript. i got the folowing code (i’m not posting all the lines..)

function addRowToTable(num){
var tblName = ‘listKPI’;
window.alert(‘here 1 : +tblName);
var tbl = document.getElementById(tblName);
window.alert(‘here 2’);
var nextRow = tbl.tBodies[0].rows.length;
window.alert(‘here 3 :’ + nextRow);
//and so on…
}

here are the html lines for the table:

<table id=”listKPI” cellpadding=0 cellspacing=0 border=1 align=”center”>
<thead>
<tr>
<td>&nbsp No. &nbsp</td>
<td>&nbsp choose &nbsp</td>
<td>&nbsp KPI Name &nbsp</td>
<td>&nbsp Owner &nbsp</td>
</tr>
</thead>
<tbody>
</tbody>
</table>

? and here’s the prooblem : the javascript lines work fine in my other pages but in this page, the function doesn’t work. the “here 1” and “here 2” show up without any problem. but “here 3” never shows up. i use IE7 (i wonder if it has something to do with the problem).

and there’s no error message shown anywhere in the browser.. ?

anyone know the posibilities of the cause of the error?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 27.2007 — window.alert('here 1 :[B][COLOR="red"]' [/COLOR][/B]+tblName);
×

Success!

Help @FelisTheCat spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...