View Full Version : Bridging server side db processing with the Content Script

02-01-2006, 10:26 PM
Nevermind....Got it working.


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

'Call Sub Routine
ToDoDetails ItemID


Thanks, bb

02-02-2006, 04:02 AM
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:

<!--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">
<br />

<div class="headers"><img src="minus.gif" class="showstate" onClick="expandcontent(this, 'sc2')" />Difference betwen Java & JavaScript?</div>
<div id="sc2" class="switchcontent">
<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">
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.

02-02-2006, 11:12 AM
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">
<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>
<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'>
<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 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>
!!! NOTE: End of subroutine call
</TD> !!!Note: Close of the area to be Expanded/Contracted

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?