473,394 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What is the best way to make a table on asp page?

Hi,

I am trying to make my table on an asp page cleaner.

Right now, I have an html table on my page that draws information from my database. The customer can enter the following on the registration page:

Provider name: "drop down menu list" option named "provider1"
If name not listed, enter name: "text box" named "other"
Provider 2 name: "drop down menu list" option named "provider2"
If name not listed, enter name: "text box" named "other2"

The problem I am having is when the table shows up on the asp account page, there is akward spacing. For instance, if the user only finds his provider in line 1 but has to enter text for provider 2, there is a larger border between these. If they only enter one provider and leave the 2nd blank, the bottom of the table is extended down but nothing is there except the solid background color.

I am wondering if there is a better way to make a table that recognizes the information entered and resizes the table depending on the information entered.

Sorry if this is very confusing, I am having a heck of a time explaining this. If there is a way to show pictures on here, I'll gladly post a picture of my table if you can tell me how.

Thanks for any insight - Jerry
Dec 1 '08 #1
10 1954
CroCrew
564 Expert 512MB
Hello Jerry,

Could you post your code. That will help in getting you an answer.

Thanks,
CroCrew~
Dec 1 '08 #2
Here is my code. Please take note, the customer will either enter a text into the "program" or the "other" text boxes. If they enter 5 programs, the table looks great. If they enter less, there is extra space at the bottom and if they enter any "other" then the border lines are much fatter. Any ideas how to clean this up a bit? Thanks

Expand|Select|Wrap|Line Numbers
  1. <center><table width="30%" border="0" cellpadding="5" cellspacing="0"> 
  2. <tr><table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
  3. <tr bgcolor="black">
  4. <th colspan="2"><font color="white" face="perpetua titling mt"><b>Title</b></font></th>
  5. <tr bgcolor="silver">
  6. <th>Program</th>
  7. <th>Points</th></tr>
  8. <tr valign="top" bgcolor="white">
  9. <td><%=objRS("Program1")%></td>
  10. <td><%=objRS("Points1")%></td></tr>
  11. <tr valign="top" bgcolor="white">
  12. <td><%=objRS("Other1")%></td>
  13. <td><%=objRS("Points1")%></td></tr>
  14. <tr valign="top" bgcolor="white">
  15. <td><%=objRS("Program2")%></td>
  16. <td><%=objRS("Points2")%></td></tr>
  17. <tr valign="top" bgcolor="white">
  18. <td><%=objRS("Other2")%></td>
  19. <td><%=objRS("Points2")%></td></tr>
  20. <tr valign="top" bgcolor="white">
  21. <td><%=objRS("Program3")%></td>
  22. <td><%=objRS("Points3")%></td></tr>
  23. <tr valign="top" bgcolor="white">
  24. <td><%=objRS("Other3")%></td>
  25. <td><%=objRS("Points3")%></td></tr>
  26. <tr valign="top" bgcolor="white">
  27. <td><%=objRS("Program4")%></td>
  28. <td><%=objRS("Points4")%></td></tr>
  29. <tr valign="top" bgcolor="white">
  30. <td><%=objRS("Other4")%></td>
  31. <td><%=objRS("Points4")%></td></tr>
  32. <tr valign="top" bgcolor="white">
  33. <td><%=objRS("Program5")%></td>
  34. <td><%=objRS("Points5")%></td></tr>
  35. <tr valign="top" bgcolor="white">
  36. <td><%=objRS("Other5")%></td>
  37. <td><%=objRS("Points5")%></td></tr>
  38. </table></td>
Dec 2 '08 #3
CroCrew
564 Expert 512MB
Hello Jerrydigital,

It’s a bit confusing what your asking help for but I think this might help you out. It seems that you have built the table and are just plopping the recordset values in the cells. Thus; if programs 1, 2, 3, 4, 5 where entered then all the cells in each row would be filled. But let’s say if someone entered just programs 1, 2, 4, 5 then there would be a blank row between programs 2 and 4.

Without seeing all your code the only advice that I could give you is to check for a value in the recordset before building the row. Something like this for each row:

Expand|Select|Wrap|Line Numbers
  1. <%
  2.     If (LEN(objRS("Program3")) > 0) Then
  3.         Response.Write("<tr valign='top' bgcolor='white'>")
  4.             Response.Write("<td>" & objRS("Program3") & "</td>")
  5.             Response.Write("<td>" & objRS("Points3") & "</td>")
  6.         Response.Write("</tr>")
  7.     End If
  8. %>
  9.  
Hope this helps,
CroCrew~
Dec 2 '08 #4
Thanks CroCrew,

I tried to implement your code but I got the following error:

Microsoft VBScript compilation error '800a0408'
Invalid character
/accountpage.asp, line 106
If LEN(objRS("AProgram1")) > 0 Then


I am sure this didn't work because of my lack of knowledge but I have posted my entire code for this page below for your review.

Expand|Select|Wrap|Line Numbers
  1. <%@ Language=VBScript %>
  2. <% Option Explicit %>
  3. <!--#include virtual="/adovbs.inc"-->
  4.  
  5. <%
  6. If session("email") = "" Then
  7.     Response.Redirect "login.html"
  8.     Response.End
  9. Else
  10.     Response.Write "You are logged in as " & session("email") & " " & "<a href='logout.asp'>" & "(Logout)" & "</a>"
  11.  
  12. End If
  13.  
  14. Dim oConn
  15. Dim connectstr, sDSNDir, dsn_name
  16.  
  17. dsn_name = "table.dsn"
  18.  
  19. sDSNDir = Server.MapPath("/_dsn")
  20. connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
  21.  
  22. Set oConn = Server.CreateObject("ADODB.Connection")
  23. oConn.Open = connectstr
  24.  
  25. Dim strSQL, strEmail
  26. Dim bolFound
  27.  
  28. strEmail = session("email")
  29. strEmail = Replace(strEmail, "'", "''")
  30.  
  31. strSQL = "SELECT * From TABLE"
  32.  
  33. Dim objRS
  34. Set objRS = Server.CreateObject("ADODB.Recordset")
  35. objRS.Open strSQL, oConn
  36. bolFound = False
  37.  
  38. Do While Not (objRS.EOF OR bolFound)
  39. If (StrComp(objRS("Email"),strEmail, vbTextCompare) = 0) Then
  40. BolFound = True
  41. Else
  42. objRS.MoveNext
  43. End If
  44. Loop
  45.  
  46. If Not bolFound Then
  47. objRS.Close
  48. Set objRS = Nothing
  49. oConn.Close
  50. Set oConn = Nothing
  51. Response.Redirect("login.html")
  52. Response.End
  53. End If
  54.  
  55. %>
  56.  
  57.  
  58. <html>
  59. <head><title>Programs/Points</title>
  60. </head>
  61.  
  62. <center><b><font face="comic sans ms" size="+3">Welcome <%=objRS("FirstName" )%></font></b></center>
  63. <br>
  64. <center><table width="85%"  border="0" cellpadding="5" cellspacing="0"> 
  65. <tr> 
  66. <td><center><table width="30%" border="0" cellpadding="5" cellspacing="0"> 
  67. <tr><table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
  68. <tr bgcolor="black">
  69. <th colspan="2"><font color="white" face="perpetua titling mt"><b>A</b></font></th>
  70. <tr bgcolor="silver">
  71. <th>A Program</th>
  72. <th>A Points</th></tr>
  73. <tr valign="top" bgcolor="white">
  74. <td><%=objRS("AProgram1")%></td>
  75. <td><%=objRS("APoints1")%></td></tr>
  76. <tr valign="top" bgcolor="white">
  77. <td><%=objRS("OtherA1")%></td>
  78. <td><%=objRS("APoints1")%></td></tr>
  79. <tr valign="top" bgcolor="white">
  80. <td><%=objRS("AProgram2")%></td>
  81. <td><%=objRS("APoints2")%></td></tr>
  82. <tr valign="top" bgcolor="white">
  83. <td><%=objRS("OtherA2")%></td>
  84. <td><%=objRS("APoints2")%></td></tr>
  85. <tr valign="top" bgcolor="white">
  86. <td><%=objRS("AProgram3")%></td>
  87. <td><%=objRS("APoints3")%></td></tr>
  88. <tr valign="top" bgcolor="white">
  89. <td><%=objRS("OtherA3")%></td>
  90. <td><%=objRS("APoints3")%></td></tr>
  91. <tr valign="top" bgcolor="white">
  92. <td><%=objRS("AProgram4")%></td>
  93. <td><%=objRS("APoints4")%></td></tr>
  94. <tr valign="top" bgcolor="white">
  95. <td><%=objRS("OtherA4")%></td>
  96. <td><%=objRS("APoints4")%></td></tr>
  97. <tr valign="top" bgcolor="white">
  98. <td><%=objRS("AProgram5")%></td>
  99. <td><%=objRS("APoints5")%></td></tr>
  100. <tr valign="top" bgcolor="white">
  101. <td><%=objRS("OtherA5")%></td>
  102. <td><%=objRS("APoints5")%></td></tr>
  103. </table></td>
  104.  
  105. <td><center><table width="30%" border="0" cellpadding="5" cellspacing="0">
  106. <tr><table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
  107. <tr bgcolor="#000000">
  108. <th colspan="2"><font color="white" face="perpetua titling mt"><b>B</b></font></th>
  109. <tr bgcolor="silver">
  110. <th>B Program</th>
  111. <th>B Points</th></tr>
  112. <tr valign="top" bgcolor="white">
  113. <td><%=objRS("BProgram1")%></td>
  114. <td><%=objRS("BPoints1")%></td></tr>
  115. <tr valign="top" bgcolor="white">
  116. <td><%=objRS("OtherB1")%></td>
  117. <td><%=objRS("BPoints1")%></td></tr>
  118. <tr valign="top" bgcolor="white">
  119. <td><%=objRS("BProgram2")%></td>
  120. <td><%=objRS("BPoints2")%></td></tr>
  121. <tr valign="top" bgcolor="white">
  122. <td><%=objRS("OtherB2")%></td>
  123. <td><%=objRS("BPoints2")%></td></tr>
  124. <tr valign="top" bgcolor="white">
  125. <td><%=objRS("BProgram3")%></td>
  126. <td><%=objRS("BPoints3")%></td></tr>
  127. <tr valign="top" bgcolor="white">
  128. <td><%=objRS("OtherB3")%></td>
  129. <td><%=objRS("BPoints3")%></td></tr>
  130. <tr valign="top" bgcolor="white">
  131. <td><%=objRS("BProgram4")%></td>
  132. <td><%=objRS("BPoints4")%></td></tr>
  133. <tr valign="top" bgcolor="white">
  134. <td><%=objRS("OtherB4")%></td>
  135. <td><%=objRS("BPoints4")%></td></tr>
  136. <tr valign="top" bgcolor="white">
  137. <td><%=objRS("BProgram5")%></td>
  138. <td><%=objRS("BPoints5")%></td></tr>
  139. <tr valign="top" bgcolor="white">
  140. <td><%=objRS("OtherB5")%></td>
  141. <td><%=objRS("BPoints5")%></td></tr>      
  142. </table></td>
  143.  
  144. <td><center><table width="30%"  border="0" cellpadding="5" cellspacing="0"> 
  145. <tr> <table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
  146. <tr bgcolor="#000000">
  147. <th colspan="2"><font color="white" face="perpetua titling mt"><b>C</b></font></th>
  148. <tr bgcolor="silver">
  149. <th>C Program</th>
  150. <th>C Points</th></tr>
  151. <tr valign="top" bgcolor="white">
  152. <td><%=objRS("CProgram1")%></td>
  153. <td><%=objRS("CPoints1")%></td></tr>
  154. <tr valign="top" bgcolor="white">
  155. <td><%=objRS("OtherC1")%></td>
  156. <td><%=objRS("CPoints1")%></td></tr>
  157. <tr valign="top" bgcolor="white">
  158. <td><%=objRS("CProgram2")%></td>
  159. <td><%=objRS("CPoints2")%></td></tr>
  160. <tr valign="top" bgcolor="white">
  161. <td><%=objRS("OtherC2")%></td>
  162. <td><%=objRS("CPoints2")%></td></tr>
  163. </table></td>     
  164. </tr> 
  165. </table>
  166. </center>
  167.  
  168. </font>
  169. </body>
  170. </html>
  171.  
  172.  
  173. <%
  174. objRS.Close
  175. Set objRS = Nothing
  176. oConn.Close
  177. Set oConn = Nothing
  178. %>
Dec 2 '08 #5
CroCrew
564 Expert 512MB
The code you post above, is it from the page "accountpage.asp"?

Line 106 does not have the following code that the error is displaying:

If LEN(objRS("AProgram1")) > 0 Then
Dec 2 '08 #6
sorry for the confusion, the code above is for the table i have that is working but is uneven as i described above.

I get the error code when I substitute the following code with the code you provided:

Expand|Select|Wrap|Line Numbers
  1. <tr valign="top" bgcolor="white"> 
  2. <td><%=objRS("AProgram1")%></td> 
  3. <td><%=objRS("APoints1")%></td></tr> 
I enter this code in place of each row(the code directly above):
Expand|Select|Wrap|Line Numbers
  1. <% 
  2.     If (LEN(objRS("AProgram1")) > 0) Then 
  3.         Response.Write("<tr valign='top' bgcolor='white'>") 
  4.             Response.Write("<td>" & objRS("AProgram1") & "</td>") 
  5.             Response.Write("<td>" & objRS("APoints1") & "</td>") 
  6.         Response.Write("</tr>") 
  7.     End If 
  8. %> 
Dec 3 '08 #7
CroCrew
564 Expert 512MB
The first thing I would have you do is to check the punctuation marks in your VBScript, particularly look out for apostrophes and commas that do not display correctly. The error is stating that your code contains an illegal character. It can happen when you copied the script, then paste into your code. For example, to 'Remark out a line we need the apostrophe, which is ASCII character 39; however if you paste from word you may get ASCII 96. I have done that before. So try looking very closely at the code you have to make sure that there are no funny apostrophes or quotes first. I would just retype the code and not copy and paste it just to make sure.

I will keep looking for more solutions.

Hope this helps,
CroCrew~
Dec 3 '08 #8
CroCrew
564 Expert 512MB
Hello jerrydigital,

Could you try adding his code right before where the error is reporting the run it again.

Expand|Select|Wrap|Line Numbers
  1. Response.Write("Post This: [" & objRS("AProgram1") & "]")
  2. Response.End
  3.  
I would like to see what the value of the record is if you don’t mind. After you run it could you post what is being displayed between the brackets (post the brackets too so we can see if there is any white space before and after the value).

Thanks,
CroCrew~
Dec 3 '08 #9
CroCrew,

I repeated my substitution I mentioned in my last post, but I followed your advice and simply typed it out instead of copy and paste. And, it works perfectly. Thank you so much for your expertise. This makes my table so much more professional.

Jerry
Dec 4 '08 #10
CroCrew
564 Expert 512MB
Glad to help.

CroCrew~
Dec 4 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

52
by: Tony Marston | last post by:
Several months ago I started a thread with the title "What is/is not considered to be good OO programming" which started a long and interesting discussion. I have condensed the arguments into a...
145
by: Mark Johnson | last post by:
Oddly enough, I found it difficult, using Google, to find a list of best-of sites based on the quality of their css packages. So I'd ask. Does anyone know of particularly good sites which are in...
47
by: Neal | last post by:
Patrick Griffiths weighs in on the CSS vs table layout debate in his blog entry "Tables my ass" - http://www.htmldog.com/ptg/archives/000049.php . A quite good article.
16
by: Jonas Smithson | last post by:
I'm going to say something now that may seem to completely contradict a previous post of mine, in which I basically said that taking a "who cares" attitude about certain browsers (because of their...
136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
4
by: Dave | last post by:
(My apologies for posting this on two forums. I have just found out the other one was the incorrect location) I am writing a VB.NET 2003 web application to operate on my company's intranet. It...
4
by: ink | last post by:
Hi all, I am trying to pull some financial data off of an HTML web page so that I can store it in a Database for Sorting and filtering. I have been thinking about this for some time and trying...
11
by: James R. Davis | last post by:
Yes, a newbie here. Though I am making progress, slowly, I am also getting more and more confused. With ASP, when I wanted to do something as trivial as updating a visitor counter, I...
1
by: Zhang Weiwu | last post by:
I know the subject line is really bad. Here is the real question: we have a web application that lists 1200 products. The web page present only 12 products at once, if you wish to see the next 12...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.