473,386 Members | 1,720 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,386 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 6370
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.