PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Thu Jun 20, 2019 1:23 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat Mar 09, 2019 10:02 am 
Offline
Forum Contributor

Joined: Fri Jul 18, 2014 1:54 pm
Posts: 179
Hi, I have php code below that is creating the html entry for the 2nd column of a table.

Syntax: [ Download ] [ Hide ]
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


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 (as shown below) 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

So this is my sneaky way around not having the proper solution which does get the value.
Syntax: [ Download ] [ Hide ]
function funcCallShellToBIAB(fldKF_Key,fldMM_Key,RowCnt) {
        var GroupCurr = document.getElementById("Table_KaraokeSchedule").rows[RowCnt].cells[1].innerHTML;
        GroupCurr = Right(GroupCurr, 5);
        GroupCurr = Left(GroupCurr, 1);
        var GroupNext = document.getElementById("Table_KaraokeSchedule").rows[RowCnt + 1].cells[1].innerHTML;
        GroupNext = Right(GroupNext, 5);
        GroupNext = Left(GroupNext, 1);
        var mytest = 0;
        var mytest2 = 0;
        //window.location='frmKaraoke_ShellToBIAB.php?RecKey=' + fldKF_Key + "&fldMM_Key=" + fldMM_Key + "&GroupCurr=" + GroupCurr + "&GroupNext=" + GroupNext;
}
 


Top
 Profile  
 
PostPosted: Fri Mar 22, 2019 10:00 am 
Offline
Briney Mod
User avatar

Joined: Mon Jan 19, 2004 7:11 pm
Posts: 6446
Location: 53.01N x 112.48W
If I were you I'd add an id to the <a />. That way you can reference it with:
Syntax: [ Download ] [ Hide ]
document.querySelector('#id-of-tag').style.fontWeight = 'bold';

_________________
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.


Top
 Profile  
 
PostPosted: Fri Mar 22, 2019 12:37 pm 
Offline
Forum Contributor

Joined: Fri Jul 18, 2014 1:54 pm
Posts: 179
Thanks pickle.

Actually someone on an html forum taught me the solution below. However I would like to try your method to see if I can get it to work and I can learn something new. So I emailed myself the link to this forum thread as a reminder to eventually get around to trying it.

John


Syntax: [ Download ] [ Hide ]
function funcCallShellToBIAB(fldKF_Key,fldMM_Key,RowCnt) {
    var GroupCurr = document.getElementById("Table_KaraokeSchedule").rows[RowCnt].cells[1].getElementsByTagName('a')[0].innerHTML; //The a name is the anchor which is between <a and </a>
    //var GroupCurr = document.getElementById("Table_KaraokeSchedule").rows[RowCnt].cells[1].getElementsByTagName('a')[0].innerText; //This gives the same value but in double quotes as text
    var GroupNext = document.getElementById("Table_KaraokeSchedule").rows[RowCnt + 1].cells[1].getElementsByTagName('a')[0].innerHTML; //The a name is the anchor which is between <a and </a>
    //var GroupNext = document.getElementById("Table_KaraokeSchedule").rows[RowCnt + 1].cells[1].getElementsByTagName('a')[0].innerText; //This gives the same value but in double quotes as text
    window.location='frmKaraoke_ShellToBIAB.php?RecKey=' + fldKF_Key + "&fldMM_Key=" + fldMM_Key + "&GroupCurr=" + GroupCurr + "&GroupNext=" + GroupNext;
}
 


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group