473,225 Members | 1,328 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,225 software developers and data experts.

get data from html table

Hi,
I have a html table with data.
Now when I select a particular row, I need the data of all the cells of that row
how would I do

Kindly help
Thanx in advance
Aug 26 '08 #1
5 6357
RamananKalirajan
608 512MB
Hi Ashish, hope this would help u out

[HTML]<html>
<head>
<script type="text/javascript">
function doThis(ths)
{
var x=(ths.id).toString();
var i=x.indexOf('r');
var num = parseInt(x.substring((i+1),x.length));
var table = document.getElementById("myTable");
var row = table.rows[num-1];
var first=row.cells[0].innerHTML;
var second = row.cells[1].innerHTML;
document.getElementById('myText1').value=first;
document.getElementById('myText2').value=second;
}
</script>
</head>
<body>
<p>Click on any Element in the Table</p>
<br/>
<table id="myTable" border="1" cellpadding="5" cellspacing="5">
<tr id="tr1" onclick="doThis(this)">
<td>Hai1</td><td>Hello1</td>
</tr>
<tr id="tr2" onclick="doThis(this)">
<td>Hai2</td><td>Hello2</td>
</tr>
<tr id="tr3" onclick="doThis(this)">
<td>Hai3</td><td>Hello3</td>
</tr>
<tr id="tr4" onclick="doThis(this)">
<td>Hai4</td><td>Hello4</td>
</tr>
<tr id="tr5" onclick="doThis(this)">
<td>Hai5</td><td>Hello5</td>
</tr>
</table> <br/>
<input type="text" id="myText1">&nbsp;&nbsp;&nbsp;&nbsp; <input type="text" id="myText2">
</body>
</html>[/HTML]

Any doubts or any probs post back it. I will try to help u out


Regards
Ramanan Kalirajan
Aug 26 '08 #2
Hi Ramanan ,

Thanx buddy,it really works
thanx a lot , u have solved a big issue
I am heartly thankful to u

God Blees u my dear frend

Regards
Ashish
Aug 26 '08 #3
RamananKalirajan
608 512MB
Hi Ramanan ,

Thanx buddy,it really works
thanx a lot , u have solved a big issue
I am heartly thankful to u

God Blees u my dear frend

Regards
Ashish
Hello Ashish be thankful to this forum. And try to help lot of guys like you. All the best. if any doubts or problem post it in the forum. I will try to help u out.

Regards
Ramanan Kalirajan
Aug 27 '08 #4
acoder
16,027 Expert Mod 8TB
The rowIndex property should be enough and can replace the first few lines of the doThis() function, i.e. ths.rowIndex can be used to index the table rows[] array.
Aug 27 '08 #5
RamananKalirajan
608 512MB
The rowIndex property should be enough and can replace the first few lines of the doThis() function, i.e. ths.rowIndex can be used to index the table rows[] array.
Hi Acoder, I tried it for dynamic data retrieval from the table. (i.e tr created dynamically) i just posted him the static one. The code can be simplified. thanks for the suggestion

Regards
Ramanan Kalirajan
Aug 27 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: Fawke101 | last post by:
Hi there, I have an application that rips data from an SQL server and displays it in columnar form on an ASP page, using a Do until RS.EOF loop. I wish to add 2 arrows to each column (up and...
2
by: Bhavin G | last post by:
Hi there , I am pretty new at javascripting and i am having this huge problem. I am using asp.net and C# webapplication. In my asp.net aspx file I have a place holder for taking an html table...
4
by: bobdedogh | last post by:
can anyone add live hyperlinks to the sortable table made by the code supplied by Machi, or know of a simple alternative bob Machi wrote Mar 10 1999, 8:00 am >>>>>>>>>>>>>> .... Hello...
31
by: Greg Scharlemann | last post by:
Given some recent success on a simple form validation (mainly due to the kind folks in this forum), I've tried to tackle something a bit more difficult. I'm pulling data down from a database and...
2
by: Dnna | last post by:
I have a table which is bound to an Internet Explorer XML data island. I'm using ASP.NET's client-side validators for an input field in the table. The problem is that if the input fields are in...
0
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format....
2
by: rmandel | last post by:
I'm very, very new to .Net but have been doing C/C++ for years. I'm having a great deal of difficulty with something that should be simple. Here's what I'm trying to do.... Display three...
9
by: sellcraig | last post by:
Microsoft access 2 tables table "data main" contains a field called "code" table "ddw1" is created from a make table query of "data main" Goal- the data in "code" field in needs to...
0
by: Jacob Donajkowski | last post by:
Once the user logs in I want to have the users switch from the Roster View to the Profile View and enter their profile infomation and save it. Then the next time they login and go to the Profile...
7
by: jwhitby3 | last post by:
Hi all, I am trying to develop what amounts to a data entry page for the company I work for, (mostly to make my job easier). I think that I am beginning to grasp php, but I am at a loss now. I...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.