Jump to content

Make 3 column table (ASP)


Recommended Posts

I am loading some images via XML and I want to put them into a table of 3 columns. How can I write that? I am using this right now for loading the XML:

<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objLst = Server.CreateObject("Microsoft.XMLDOM")
Set objHdl = Server.CreateObject("Microsoft.XMLDOM")

objXML.async = False

objXML.Load (Server.MapPath("test.xml"))

If objXML.parseError.errorCode <> 0 Then
'handle the error
End If

Set objLst = objXML.getElementsByTagName("course")
noOfHeadlines = objLst.length

Response.Write("<table border=""1""><tr>")
For i = 0 To (noOfHeadlines - 1)
Set objHdl = objLst.item(i)
Response.Write("<td><img src=""" & objHdl.childNodes(5).childNodes(0).text & """ /><br></td>")
Next
Response.Write("</tr></table>")
%>

Link to comment
Share on other sites

I figured it out:

<%
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
Set objLst = Server.CreateObject("Microsoft.XMLDOM")
Set objHdl = Server.CreateObject("Microsoft.XMLDOM")

objXML.async = False

objXML.Load (Server.MapPath("test.xml"))

If objXML.parseError.errorCode <> 0 Then
'handle the error
End If

Set objLst = objXML.getElementsByTagName("course")
noOfHeadlines = objLst.length
numElements = noOfHeadlines 
numCols = 3 

Response.Write("<table width=""800"" border=""1"">")
For i = 0 To (noOfHeadlines - 1)
needFooter = true
Set objHdl = objLst.item(i)
if i mod numCols = 0 then
	Response.Write("<tr>")
end if
Response.Write("<td width=""33%""><div class=""tTip"" title=""" & objHdl.childNodes(1).childNodes(0).text & """><a href=""" & objHdl.childNodes(7).childNodes(0).text & """><img src=""" & objHdl.childNodes(5).childNodes(0).text & """ /></a></div></td>")
if i mod numCols = numCols - 1 then
	Response.Write("</tr>")
	needFooter = false
end if
Next

if needFooter then
Response.Write("<td colspan=""" &	numCols - (i mod numCols) &	"""> </td></tr>")
end if

Response.Write("</table>")
%>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.