/    Sign up×
Community /Pin to ProfileBookmark

unable to capture a row–Please help

HI,
I am fairly new to programming. From 2 days I am struggling to get this.
we have a data table and I want to get a cell data in that datatable and therefore I am invoking a js on a button clilck
My script is

function geocodeLevelHighlight(){
var candidateTableFirstRow =
document.getElementById(‘candidateList’).rows[0].cells;
alert(candidateTableFirstRow[1].innerHTML);
}

and source(from view->source) of the data table looks like

<table id=”_id10:panelTabSetCpg:candidateList” rows=”5″>
<thead>
<tr>
<th><span>Source</span></th>
<th><span>Name</span></th>
</tr>
</thead>
<tbody>
<tr id=”_
id10:panelTabSetCpg:candidateList:0″>
<td><span>Original</span></td>
<td><span>XYZ</span></td>
</tr>
</tbody>
</table>

ANy help is highly appreciated.
Thanks in advance.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@Angry_Black_ManApr 04.2008 — hi. place your code between [code[COLOR="Black"]][[/COLOR]/code] tags. those smileyfaces (among other things) make the code difficult to decipher.

first, in order to program, you have to know how to debug. if you use internet explorer, they have made the process as convoluted as possible. however, generally when there is a script error, you will receive, on the bottom left hand corner of your browser, a yellow triangle with an exclamation point in it. by clicking this, you bring up IE's error console.

if you use firefox, under the tools menu is a javascript (or error) console. the errors start from top to bottom, and add to the bottom. for troubleshooting purposes, open this console, clear it, and then do whatever it is that doesnt work as expected. once you look at this console, you will see the error message (if any).

the first error i got when executing the code was:

document.getElementById("candidateList") has no properties[/quote]

this means that there is no element on the page with the exact name "candidateList". the code looked for SOMETHING that had the attribute:

&lt;... id="candidateList" ...&gt;

and didnt find it. there may be more errors, but debugging happens one line at a time.
×

Success!

Help @userjavascript 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.20,
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,
)...