/    Sign up×
Community /Pin to ProfileBookmark

how to check table data on table events

hello,

am new to this javascript thing, i want to know how to identify a table cell/data to execute a javascript events on the table tag. can anyone help me on this?

example:
<form name=”myform” onBlur=”MyEventsHere()”>
<table border=”1″ width=”302″ height=”176″>
<tr>
<td width=”89″ height=”85″><input type=”text” name=”name1″></td>
<td width=”90″ height=”85″><input type=”text” name=”name2″></td>
<td width=”95″ height=”85″><input type=”text” name=”name3″></td>
</tr>
</table>
<p><input type=”submit”> </p>
</form>

i want to make an event on the name2. i want it on my table tag, is it possible? please help me on this…

lexthor

to post a comment
JavaScript

9 Comments(s)

Copy linkTweet thisAlerts:
@JonaNov 25.2004 — <i>
</i>&lt;input type="text" name="name2" onblur="MyEventsHere()"&gt;
Copy linkTweet thisAlerts:
@lexthorauthorNov 25.2004 — i want it on my table tag...

<form name="myform">

<table border="1" width="302" height="176" onBlur="MyEventsHere()">

<tr>

<td width="89" height="85"><input type="text" name="name1"></td>

<td width="90" height="85"><input type="text" name="name2"></td>

<td width="95" height="85"><input type="text" name="name3"></td>

</tr>

</table>

<p><input type="submit"> </p>

</form>

i like to identify it with the element id... maybe it need a looping... don't you think?

lexthor
Copy linkTweet thisAlerts:
@JPnycNov 25.2004 — No one yet has any idea what it is you're trying to do.
Copy linkTweet thisAlerts:
@lexthorauthorNov 25.2004 — can someone help me on this...

lexthor
Copy linkTweet thisAlerts:
@JonaNov 25.2004 — [i]Originally posted by lexthor [/i]

[B]can someone help me on this...



lexthor [/B]
[/QUOTE]


[font=trebuchet ms]Did you just see Dunsel's post? I think it would help if you tried to explain better.[/font]
Copy linkTweet thisAlerts:
@lexthorauthorNov 25.2004 — can i put an event on the table tag? something like this... <table border="1" width="302" height="176" onBlur="MyEventsHere()">

lexthor
Copy linkTweet thisAlerts:
@JonaNov 25.2004 — [i]Originally posted by lexthor [/i]

[B]can i put an event on the table tag? something like this... <table border="1" width="302" height="176" onBlur="MyEventsHere()">



lexthor [/B]
[/QUOTE]


[font=trebuchet ms]Yes.[/font]
Copy linkTweet thisAlerts:
@lexthorauthorNov 25.2004 — how can i put identify the td example in name2, i want it to loop to get the element id on the cell?

lexthor
Copy linkTweet thisAlerts:
@JonaNov 25.2004 — [font=trebuchet ms]There is no "focus" or "blur" event for a table, though, so you'll have to use "onclick" or something similar.[/font]

<i>
</i>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang="en" dir="ltr"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Example&lt;/title&gt;
&lt;script type="text/javascript"&gt;&lt;!--
function myFunction(o,id){
var s = o.childNodes, f = 0;
if(!s) return;
for(var i=0; i&lt;s.length; i++){
if(s[i].id == id){
alert("Found row "+id+" in the "+o.nodeName+".");
f=1;
}
if(s[i].childNodes){
myFunction(s[i],id);
}
}
if(f==0){
alert("Didn't find row "+id+" in the "+o.nodeName+".");
}
}
//--&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table onclick="myFunction(this,'data2')"&gt;
&lt;tr&gt;
&lt;td id="data2"&gt;Word.&lt;/td&gt;
&lt;td&gt;Word.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Word.&lt;/td&gt;
&lt;td&gt;Word.&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;
×

Success!

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