The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

> Using Javascript to obtain a table value
bowlesj
post Mar 9 2019, 09:54 AM
Post #1


Novice
**

Group: Members
Posts: 27
Joined: 11-June 15
Member No.: 22,710



Hi, I have php code below that is creating the html entry for the 2nd column of a table.
CODE
echo("<td><a href='frmKaraokeUpdateSongGroup.php?RecKey=$fldKF_Song_LU&fldKF_Key=$fldKF_Key'>$fldKF_Group</td>\n");


I am trying to get at the $fldKF_Group using javascript. I know how to find the cell and row using the command below but I can't figure out the part at the end where I mark it in bold.
var GroupCurr = document.getElementById("Table_KaraokeSchedule").rows[RowCnt].cells[1].can't figure out what to put here[color=#FF0000];


I know how to do it if there is no href in the table cell (using .innerhtml). I know how to do it if there is an input textbox in the table cell. I have some example code to find the value of the href. In the past I have used .innerhtml and used the left string or right string commands to get at the data but I prefer not to do that. Google searches with parts of the command are not finding anything.

Any help would be appreciated.

Thanks,
John

This post has been edited by bowlesj: Mar 9 2019, 09:55 AM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
 
Reply to this topicStart new topic
Replies
Christian J
post Mar 9 2019, 12:52 PM
Post #2


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(bowlesj @ Mar 9 2019, 03:54 PM) *

CODE
echo("<td><a href='frmKaraokeUpdateSongGroup.php?RecKey=$fldKF_Song_LU&fldKF_Key=$fldKF_Key'>$fldKF_Group</td>\n");


Note that the link above is lacking its </a> end tag.

QUOTE
I know how to find the cell and row using the command below but I can't figure out the part at the end where I mark it in bold.
var GroupCurr = document.getElementById("Table_KaraokeSchedule").rows[RowCnt].cells[1].can't figure out what to put here[color=#FF0000];

The following should return the contents of the first link in the cell:

CODE
var GroupCurr = document.getElementById("Table_KaraokeSchedule").rows[RowCnt].cells[1].getElementsByTagName('a')[0].innerHTML;

If you only want the plain link text you might also use innerText instead of innerHTML.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
bowlesj
post Mar 9 2019, 01:59 PM
Post #3


Novice
**

Group: Members
Posts: 27
Joined: 11-June 15
Member No.: 22,710



Thank you Christian, now I understand this one too.
document.getElementById("Table_KaraokeSchedule").rows[MyRow].cells[6].getElementsByTagName('input')[0].checked=false;

John
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Posts in this topic


Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 25th April 2024 - 07:57 PM