SitePoint Sponsor

User Tag List

Results 1 to 13 of 13

Thread: Layer help?

  1. #1
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Layer help?

    This is part of my website

    http://membres.lycos.fr/iamadam/main.php

    Its a ranking so I have to cut and paste the rows often. This presents a problem becasue if I move around the rows, the color pattern will not be the same.

    Now its light blue - dakr blue - light blue - dark blue etc.

    If I move around the rows, sometimes its dakr blue - dark blue - light blue - light blue etc.

    I just want to move the tezt in the rows but I want the color pattern of the rows to remain the same. Is this somehow possible by using layers? Or some other method?

    Thanks in advance
    Last edited by IamAdam; Apr 16, 2002 at 14:11.

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey,

    Do you just want alternating rows? i.e. light - dark - light - dark?

    This can easily be done with PHP or JavaScript.

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just to let you know your site dont load

  4. #4
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep, I just want alternating rows.

    Could you tell me hwo I would go about doing that with php or javascript?

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you know any PHP or JavaScript?

    it would be even easier for you if you were using a database.

    I have a bit of code here but it wont make much sense if you dont know some PHP.

  6. #6
    SitePoint Enthusiast
    Join Date
    Apr 2002
    Posts
    51
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah BTW your site isn't loading for up me anymore.

  7. #7
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    k, thanks for telling me. I fixed the URL.

    yeah, i do know some javascript and php although not much.

  8. #8
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So, does anyone know how would I go about doing that in javascript/php?

  9. #9
    SitePoint Member Pricey's Avatar
    Join Date
    Apr 2002
    Location
    Qld, Australia
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im pretty sure this can be done with css too

  10. #10
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <html>
    <
    head>
        <
    title>Alernate row colours</title>
        <
    meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
        <
    style>
            
    td {
                
    background-color#ffffff;
                
    font-size11px;
                
    font-weightbold;
                
    padding5px;
            }
            
            
    td.cell1 {
                
    color#cc3300;
                
    background-color#eeeeee;
            
    }
            
            
    td.cell2 {
                
    color#3366cc;
                
    background-color#ffffff;
            
    }
        
        </
    style
        
        <
    script type="text/jscript">
        

        
        
        function 
    setCellsDHTML(strTableIDstrClasses) {
        
            var 
    objTable document.getElementById(strTableID);
            var 
    objRows;
            var 
    objCells;
            
            var 
    arrClasses strClasses.split(",");
            var 
    intClassCnt arrClasses.length;
            var 
    strClass;
            
            if (
    objTable != null) {
                
                
    //Get the table rows
                
    objRows objTable.rows;
                
                
    //Loop around rows
                
    for (0objRows.lengthi++) {
                    
    objCells objRows[i].cells;
                    
                    
    //Get style class for row cell
                    
    strClass arrClasses[(intClassCnt)]; 
                    
                    
    //Loop around cells
                    
    for (0objCells.lengthj++) {
                        
    objCells[j].className strClass;
                    }
                }
            
            }    
        
        }
        
        function 
    setCellsDOM(strTableIDstrClasses) {
        
            var 
    objTable document.getElementById(strTableID);
            var 
    objRows;
            var 
    objCells;
            
            var 
    arrClasses strClasses.split(",");
            var 
    intClassCnt arrClasses.length;
            var 
    strClass;
            
            if (
    objTable != null) {

                
    //Get the table rows
                
    objRows objTable.getElementsByTagName("TR");

                
    //Loop around rows
                
    for (0objRows.lengthi++) {
                    
    //Get style class for row cell
                    
    strClass arrClasses[(intClassCnt)];
        
                    
    //Get cells
                    
    objCells objRows[i].getElementsByTagName("TD");
                    
                    
    //Loop around cells
                    
    for (0objCells.lengthj++) {
                        
    ///???
                        //Not sure why the attribute is named 'className'
                        //asI'd expect it to be named 'class'.
                        
    objCells[j].setAttribute("className"strClass);
                    }
        
                }
            }    
        
        }
        
        
        
    </script>
    </head>

    <body>

    <input type="button" value="Set cells with DHTML" onclick="setCellsDHTML('testtable', 'cell1,cell2')">

    <input type="button" value="Set cells with DOM" onclick="setCellsDOM('testtable', 'cell2,cell1')">


    <table id="testtable" style="width: 400px">
    <tr>
        <td>Row 1 Cell 1</td>
        <td>Row 1 Cell 2</td>
    </tr>
    <tr>
        <td>Row 2 Cell 1</td>
        <td>Row 2 Cell 2</td>
    </tr>
    <tr>
        <td>Row 3 Cell 1</td>
        <td>Row 3 Cell 2</td>
    </tr>
    <tr>
        <td>Row 4 Cell 1</td>
        <td>Row 4 Cell 2</td>
    </tr>
    <tr>
        <td>Row 5 Cell 1</td>
        <td>Row 5 Cell 2</td>
    </tr>
    <tr>
        <td>Row 6 Cell 1</td>
        <td>Row 6 Cell 2</td>
    </tr>
    </table>



    </body>
    </html> 
    or a better way

    PHP Code:
    <script>
    var 
    r=document.getElementById('stripe').childNodes[0].childNodes
    // - get 'stripe' element (the table), TBODY tag,    children of TBODY (TR tags)
    var l=r.length // - total number of TR tags belonging to the TBODY tag
    for (i=0;i<l;i++){ 
        if (
    i%== 0){} 
        else {
    r[i].style.backgroundColor='#cccc66';}
        }
    </script> 

  11. #11
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmm, thx, this all looks good

    justr a few problems..

    with the 1st script, there are 2 buttons at the top and u gota press them in order for ceels to be striped.

    the 2nd script give me an error that an objext was expected. I gave the table id "stripe" but theres still the error

  12. #12
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <table border="1" cellpadding="2" cellspacing="0" id="stripe">
        <
    tr><th>a</th><th>b</th><th>c</th><th>d</th></tr>
        <
    tr><td>1</td><td>2</td><td>19145</td><td3</td></tr>
        <
    tr><td>1</td><td>2</td><td>3</td><td>4</td></tr>
    </
    table>
    <
    script>
    var 
    r=document.getElementById('stripe').childNodes[0].childNodes
    // - get 'stripe' element (the table), TBODY tag,    children of TBODY (TR tags)
    var l=r.length // - total number of TR tags belonging to the TBODY tag
    for (i=0;i<l;i++){ 
        if (
    i%== 0){} 
        else {
    r[i].style.backgroundColor='#cccc66';}
        }
    </script> 

  13. #13
    SitePoint Addict
    Join Date
    Apr 2002
    Posts
    395
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile

    Yes!!!!!!!! It works. Hurrah:-)

    Thanks alot


Bookmarks

Posting Permissions

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