Results 1 to 3 of 3

Thread: Bridging server side db processing with the Content Script

  1. #1
    Join Date
    Feb 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Bridging server side db processing with the Content Script

    Nevermind....Got it working.

    http://www.dynamicdrive.com/dynamici...chcontent2.htm

    Little guidance for a novice would be greatly appreciated....

    My page is ASP. Server side processing is connecting to a database, returning multiple recordsets, and building a table with multiple rows and sub-table/rows. The first column contains the +- images. I'm attempting to expand and contract the sub-data. The sub-data comes from a second recordset. I can get the 'expand all | contract all' to work. I've assigned a different "id=" in each of the table data elements that encapsulate a second table with the sub-data. I realize I'm struggle with the "id=" between the <td...><img...onclick=...>, but my javascript knowledge is to limited at this point to understand how to bridge the server side processing with the client side processing. Following is a cutout of the code:

    While Not ToDoHeaderrs.EOF
    response.Write "<TR bordercolor='" & arrColor(iIndex) & "' BGCOLOR='" & arrColor(iIndex) & "'>" & vbcrlf
    %>
    <TD class="headers" valign="middle" width="15"><img src="../Images/minus.gif" class="showstate" onClick="expandcontent(this, 'sc3')" /></td>
    <%
    response.Write "<TD valign='middle'><left><a class='normal' href='ToDoDetails.asp?ItemID=" & ToDoHeaderrs(0) & "'>" & ToDoHeaderrs(1) & "</a>" & "</TD>" & vbCrLf
    response.write "<TD valign='middle'><center>" & ToDoHeaderrs(2) & "</TD>" & VBCrLf
    response.write "<TD valign='middle'><center>" & ToDoHeaderrs(3) & "</TD>" & VBCrLf
    response.write "<TD valign='middle'><center>" & ToDoHeaderrs(4) & "</TD>" & VBCrLf
    response.write "<TD valign='middle'><center>" & ToDoHeaderrs(5) & "</TD>" & VBCrLf
    response.Write "<TD valign='middle'><left><a class='normal' href='UpdToDo.asp?ItemID=" & ToDoHeaderrs(0) & "'>" & "Update" & "</a>" & "</TD>" & vbCrLf
    response.Write "<TD valign='middle'><left><a class='normal' href='DelToDo.asp?ItemID=" & ToDoHeaderrs(0) & "'>" & "Delete" & "</a>" & "</TD>" & vbCrLf
    response.Write "</TR>" & vbcrlf
    response.Write "<TR>" & vbcrlf
    ' response.write "<TD class='switchcontent' id='sc3'>" & vbcrlf
    response.write "<TD colspan='8' class='switchcontent' id=" & iExpand & ")>" & vbcrlf

    DIM ItemID
    ItemID=ToDoHeaderrs(0)
    '***********************************************************************************************************
    'Call Sub Routine
    '***********************************************************************************************************
    ToDoDetails ItemID

    ToDoHeaderrs.Movenext


    Thanks, bb
    Last edited by bstylen; 02-03-2006 at 02:05 AM.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Unfortunately ASP is completely alien to me. However, as long as you can get ASP to output the content to contract/expand per the script's structure, it really shouldn't matter. This structure as shown in the demo is:

    Code:
    <!--Optional Expand/ Contact All links. Remove if desired-->
    <div style="margin-bottom: 5px"><a href="javascript:sweeptoggle('contract')">Contract All</a> | <a href="javascript:sweeptoggle('expand')">Expand All</a></div>
    
    <div class="headers"><img src="minus.gif" class="showstate" onClick="expandcontent(this, 'sc1')" />What is JavaScript?</div>
    <div id="sc1" class="switchcontent">
    CONTENT 1
    </div>
    <br />
    
    <div class="headers"><img src="minus.gif" class="showstate" onClick="expandcontent(this, 'sc2')" />Difference betwen Java & JavaScript?</div>
    <div id="sc2" class="switchcontent">
    CONTENT 2
    </div>
    <br />
    
    <table border="0" cellspacing="0" cellpadding="0">
      <tr><td class="headers"><img src="minus.gif" class="showstate" onClick="expandcontent(this, 'sc3')" />What is DHTML? (table example)</td></tr>
      <tr><td id="sc3" class="switchcontent">
    CONTENT 3
    </td></tr>
    </table>
    As long as you can get ASP to output the correct container tags, whether it's a DIV or a table, then insert the content to expand/contract per the code in red above, it will work. Your ASP must also input the appropriate ID and onClick codes, and increment the IDs accordingly like above.

  3. #3
    Join Date
    Feb 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The problem I'm running into is the section in question on my page looks more like this after load:

    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td class="headers"><img src="minus.gif" class="showstate" onClick="expandcontent(this, 'sc3')" /></td>
    <TD valign='middle'><left><a class='normal' href='ToDoDetails.asp?ItemID=115'>dbData1</a></TD>
    <TD valign='middle'><center>dbData2</TD>
    <TD valign='middle'><center>dbData3</TD>
    <TD valign='middle'><center>dbData4</TD>
    <TD valign='middle'><center>dbData5</TD>
    <TD valign='middle'><left><a class='normal' href='UpdToDo.asp?ItemID=115'>Update</a></TD>
    <TD valign='middle'><left><a class='normal' href='DelToDo.asp?ItemID=115'>Delete</a></TD>
    </tr>
    <tr>
    <TD colspan='8' class='switchcontent' id=987654321> !!!NOTE: Start of expand/collapse..In this example, I'm generating the id server side
    !!! NOTE: Start of sub routine call from within the TD tag above
    <TABLE width='100%' cellpadding='0' cellspacing='0' border='1' bordercolor='#666666'>
    <TR bordercolor='#666666'>
    <TD>
    <TABLE width='100%' cellspacing=0 border=0 cellpadding=5>
    <TR bordercolor='gray' BGCOLOR='gray'>
    <TD valign='top' width='10'><H4></TD>
    <TD valign='top' width='115'><left><H4><U>Status Date</TD>
    <TD valign='top'><left><H4><U>Status</U></TD>
    </TR>
    <TR bordercolor='#FFFFFF' BGCOLOR='#FFFFFF'>
    <TD valign='top' width='10'><H4></TD>
    <TD valign='top' width='115'><left><p>dbDataX</TD>
    <TD valign='top'><left><p>dbDataY</TD>
    </TR>
    </TR>
    </center>
    </TABLE>
    </TD>
    </TR>
    </TABLE>
    !!! NOTE: End of subroutine call
    </TD> !!!Note: Close of the area to be Expanded/Contracted
    </TR>

    In the output above, I added the !!! NOTE:..... to point out the area being expanded and contracted. It not actually in the source.

    The whole sequence repeats itself 15-20 timee per my desired result. When I click on any of the individual +- images, only the content of the first one opens if I name the id=sc3 for each section. If I dynamically generate a different <td id=1234... , <td id=1235 and so on, it doesn't match that in the onclick function call, thus I get page errors.

    Any ideas?
    Last edited by bstylen; 02-02-2006 at 01:15 PM.

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
  •