www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to reference to java table inside html

Hybrid View

  1. #1
    Join Date
    Mar 2013
    Posts
    1

    How to reference to java table inside html

    Dear All, can you pls help. I have the below code on my SharePoint 2007. My problem is that if I place this code above a SharePoint list does not calculate, if I put this under the list it calculates. Can you pls let me know how I could display the table above the list that would calculate the number of "On track" items.
    =====


    <html>
    <head>

    <script language="JavaScript" type="text/JavaScript">


    var x = document.getElementsByTagName("TD") // find all of the TDs

    var Ont=0;

    var i=0;

    for (i=0;i<x.length;i++)
    {

    if (x[i].className=="ms-vb2") //find the TDs styled for lists
    {

    if (x[i].innerHTML=="On track")
    {
    Ont++
    x[i].style.backgroundColor='palegreen'; // set the background color
    x[i].style.color='Black'; //set the font color
    }

    }
    }

    document.write('<table id="test" style="margin-right:5" style="float:left" class="main1" border=1 cellspacing=0 cellpadding=2 bordercolor="#EEEEEE">' );


    document.write(
    '<tr bgcolor="#EEEEEE"> <td > <font color="#319ACE"> ' + 'SISRR' +
    '<td bgcolor="#EEEEEE"</td> <font color="#319ACE">' + ' # ' +
    '<td bgcolor="#EEEEEE"</td> <font color="#319ACE">' + ' Zita V. ' +
    '<td bgcolor="#EEEEEE"</td> <font color="#319ACE">' + ' Gergely P. ' +
    '<td bgcolor="#EEEEEE"</td> <font color="#319ACE">' + ' Peter M. ' +
    '<td bgcolor="#EEEEEE"</td> <font color="#319ACE">' + ' Balazs G. ' +
    '<td bgcolor="#EEEEEE"</td> <font color="#319ACE">' + ' Christian B.I. ' +
    '</td></tr>');

    document.write(
    '<tr align="right"><td >' + 'Very high ' +
    '<td </td> ' + Ont +
    '<td </td> ' + Ont +
    '<td </td> ' + Ont +
    '<td </td> ' + Ont +
    '<td </td> ' + Ont +
    '<td </td> ' + Ont +
    '</td></tr>');

    document.write('</table id="test"></center>');


    table = document.getElementById('test');

    </script>

    </head>
    </html>

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,330

    Lightbulb

    You might want to start from scratch...

    The 'language=javascript' is the tip off that this is very old code as it has become deprecated.

    You have displays between the '<td </td>' elements, which is also the incorrect syntax.

    You are trying the change the contents of table elements with a class of 'ms-vb2'
    but there is no class definition and it is not assigned to any of the elements in your script.

    If you use document.write() statements anytime AFTER the page has been rendered initially,
    it will reload the original code as if you had done nothing since the last earlier load.

    Finally, you should check the error console if you are using FF or Chrome browsers to get a list of the errors.

    BTW: You should use [ code] and [ /code] tags (without the spaces)
    around you script to make it more readable on the forum and it preserves the spacing layout.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles