SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do you contract and expand the postings?

    I am designing a forum in ASP and really liked the way vBullettin have allowed postings in this forum to expand and contract - looks very cool....

    I understand this is done using c/side javascript,
    So I was wondering how they did it?

    I have looked at the code, even tried it but to no avail am I missing something?

    Here is my code:

    g_TopicIDh = g_TopicID & "h"
    g_TopicIDe = g_TopicID & "e"

    Response.Write "<div id=" & g_TopicIDh & " style=""display:none"">"
    Response.Write "<table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'>"
    Response.Write "<tr><td class='lefttablecol'><img src='images/plus.gif' border=0 alt='Expand posting' onclick=""contract(" & g_TopicIDe & ");expand(" & g_TopicIDh & ");""> Not showing</td></tr>" & vbcrlf
    Response.Write "</table>" & vbcrlf
    Response.Write "</div>" & vbcrlf
    Response.Write "<div id=" & g_TopicIDe & " style=""display:show"">" & vbcrlf
    Response.Write "<table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'>" & vbcrlf
    Response.Write "<tr><td width='150' class='lefttablecol'><img src='images/minus.gif' border=0 alt='Minimise posting' onclick=""contract(" & g_TopicIDh & ");expand(" & g_TopicIDe & ");""> <font size='1'>" & g_Update & "</font></td>" & vbcrlf
    Response.Write "<td class='lefttablecol'>"
    %>
    <!--#include file="includes/topiclinks.inc"-->
    <%
    Response.Write "</td></tr>" & vbcrlf

    response.write "</table>"
    response.write "</div>"


    Any ideas?

  2. #2
    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)

    Plain javascript example

    Plain javascript now just add it into .asp

    PHP Code:
    <script>

    function 
    contract(id)
    {
        if (
    document.getElementById(id).style.display=='none')
        {
            
    document.getElementById(id).style.display='block';
        }
        else
        {
            
    document.getElementById(id).style.display='none';
        }
    }

    </script>

    <div id="1">
    <table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'>
    <tr><td class='lefttablecol'><img src='images/plus.gif' border=0 alt='Expand posting' onclick="contract(2);"></td></tr>
    </table>
    </div>




    <div id="2">
    <table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'>
    <tr><td class='lefttablecol'><img src='images/minus.gif' border=0 alt='Minimise posting' onclick="contract(2);"></td>
    <td class='lefttablecol'>

    </td></tr>

    </table>
    </div> 

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply...

    Showing a js error that it is expecting ')' in the line highlighted below??

    any ideas?

    <div id='2e'><table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'><tr><td class='lefttablecol'><img src='images/plus.gif' border=0 alt='Expand posting' onclick="contract(2e);">&nbsp;Not showing</td></tr>
    </table>
    </div>


    cheers...

  4. #4
    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)
    Try this I was just messing about:P

    PHP Code:
    <script>
    function 
    dummytxt()
    {
        for (
    a=0,b=5;a<b;a++){document.write("This is dummy text");}
    }

    function 
    contract(id)
    {
    with (document)
        {
            if (
    getElementById(id).style.display=='none')
            {
                
    getElementById(id).style.display='block';
                
    getElementById('minmax').src="http://i.sitepoint.com/fi/lastpost.gif";
                
    getElementById('minmax').alt='Minimise posting';
            }
            else
            {
                
    getElementById(id).style.display='none';
                
    getElementById('minmax').src="http://i.sitepoint.com/fi/sortasc.gif";
                
    getElementById('minmax').alt='Expand posting';
            }
        }
    }

    </script>

    <div id="header">
    <table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'>
    <tr><td class='lefttablecol'><img name='minmax' id='minmax'  src='http://i.sitepoint.com/fi/sortasc.gif' border=0 alt='Minimise posting' onclick="contract(2);"></td></tr>
    </table>
    </div>

    <div id="2">
        <table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'>
            <tr>
                <td class='lefttablecol'><img name='minmax' id='minmax' src='http://i.sitepoint.com/fi/lastpost.gif' border=0 alt='Minimise posting' onclick="contract(2);"></td>
                <td class='lefttablecol'><script>dummytxt()</script></td>
            </tr>
        </table>
    <script>dummytxt()</script>
    </div> 

  5. #5
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    How does this work then?

    Could you explain please....

    I appreciate this...

  6. #6
    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)
    when using words, you need to use a string


    so onclick="contract('2e')

    PHP Code:
    <div id='2e'><table valign='top' width='100%' cellpadding='2' cellspacing='0' bgcolor='#EBF1F7' border='1' bordercolor='#ffffff'><tr><td class='lefttablecol'><img src='images/plus.gif' border=0 alt='Expand posting' onclick="contract('2e')"Not showing</td></tr
    </
    table
    </
    div

  7. #7
    SitePoint Evangelist
    Join Date
    Jun 2001
    Location
    London
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks so much .... looking good now.

    Cheers



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
  •