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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jerrydigital
    New Member
    • Oct 2008
    • 67

    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
  • CroCrew
    Recognized Expert Contributor
    • Jan 2008
    • 564

    #2
    Hello Jerry,

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

    Thanks,
    CroCrew~

    Comment

    • jerrydigital
      New Member
      • Oct 2008
      • 67

      #3
      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

      Code:
      <center><table width="30%" border="0" cellpadding="5" cellspacing="0"> 
      <tr><table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
      <tr bgcolor="black">
      <th colspan="2"><font color="white" face="perpetua titling mt"><b>Title</b></font></th>
      <tr bgcolor="silver">
      <th>Program</th>
      <th>Points</th></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Program1")%></td>
      <td><%=objRS("Points1")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Other1")%></td>
      <td><%=objRS("Points1")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Program2")%></td>
      <td><%=objRS("Points2")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Other2")%></td>
      <td><%=objRS("Points2")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Program3")%></td>
      <td><%=objRS("Points3")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Other3")%></td>
      <td><%=objRS("Points3")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Program4")%></td>
      <td><%=objRS("Points4")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Other4")%></td>
      <td><%=objRS("Points4")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Program5")%></td>
      <td><%=objRS("Points5")%></td></tr>
      <tr valign="top" bgcolor="white">
      <td><%=objRS("Other5")%></td>
      <td><%=objRS("Points5")%></td></tr>
      </table></td>

      Comment

      • CroCrew
        Recognized Expert Contributor
        • Jan 2008
        • 564

        #4
        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:

        Code:
        <%
        	If (LEN(objRS("Program3")) > 0) Then
        		Response.Write("<tr valign='top' bgcolor='white'>")
        			Response.Write("<td>" & objRS("Program3") & "</td>")
        			Response.Write("<td>" & objRS("Points3") & "</td>")
        		Response.Write("</tr>")
        	End If
        %>
        Hope this helps,
        CroCrew~

        Comment

        • jerrydigital
          New Member
          • Oct 2008
          • 67

          #5
          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("APro gram1")) > 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.

          Code:
          <%@ Language=VBScript %>
          <% Option Explicit %>
          <!--#include virtual="/adovbs.inc"-->
          
          <%
          If session("email") = "" Then
              Response.Redirect "login.html"
              Response.End
          Else
          	Response.Write "You are logged in as " & session("email") & " " & "<a href='logout.asp'>" & "(Logout)" & "</a>"
          	
          End If
          
          Dim oConn
          Dim connectstr, sDSNDir, dsn_name
          
          dsn_name = "table.dsn"
          
          sDSNDir = Server.MapPath("/_dsn")
          connectstr = "filedsn=" & sDSNDir & "/" & dsn_name
          
          Set oConn = Server.CreateObject("ADODB.Connection")
          oConn.Open = connectstr
          
          Dim strSQL, strEmail
          Dim bolFound
          
          strEmail = session("email")
          strEmail = Replace(strEmail, "'", "''")
          
          strSQL = "SELECT * From TABLE"
          
          Dim objRS
          Set objRS = Server.CreateObject("ADODB.Recordset")
          objRS.Open strSQL, oConn
          bolFound = False
          
          Do While Not (objRS.EOF OR bolFound)
          If (StrComp(objRS("Email"),strEmail, vbTextCompare) = 0) Then
          BolFound = True
          Else
          objRS.MoveNext
          End If
          Loop
          
          If Not bolFound Then
          objRS.Close
          Set objRS = Nothing
          oConn.Close
          Set oConn = Nothing
          Response.Redirect("login.html")
          Response.End
          End If
          
          %>
          
          
          <html>
          <head><title>Programs/Points</title>
          </head>
          
          <center><b><font face="comic sans ms" size="+3">Welcome <%=objRS("FirstName" )%></font></b></center>
          <br>
          <center><table width="85%"  border="0" cellpadding="5" cellspacing="0"> 
          <tr> 
          <td><center><table width="30%" border="0" cellpadding="5" cellspacing="0"> 
          <tr><table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
          <tr bgcolor="black">
          <th colspan="2"><font color="white" face="perpetua titling mt"><b>A</b></font></th>
          <tr bgcolor="silver">
          <th>A Program</th>
          <th>A Points</th></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("AProgram1")%></td>
          <td><%=objRS("APoints1")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherA1")%></td>
          <td><%=objRS("APoints1")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("AProgram2")%></td>
          <td><%=objRS("APoints2")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherA2")%></td>
          <td><%=objRS("APoints2")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("AProgram3")%></td>
          <td><%=objRS("APoints3")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherA3")%></td>
          <td><%=objRS("APoints3")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("AProgram4")%></td>
          <td><%=objRS("APoints4")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherA4")%></td>
          <td><%=objRS("APoints4")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("AProgram5")%></td>
          <td><%=objRS("APoints5")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherA5")%></td>
          <td><%=objRS("APoints5")%></td></tr>
          </table></td>
           
          <td><center><table width="30%" border="0" cellpadding="5" cellspacing="0">
          <tr><table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
          <tr bgcolor="#000000">
          <th colspan="2"><font color="white" face="perpetua titling mt"><b>B</b></font></th>
          <tr bgcolor="silver">
          <th>B Program</th>
          <th>B Points</th></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("BProgram1")%></td>
          <td><%=objRS("BPoints1")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherB1")%></td>
          <td><%=objRS("BPoints1")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("BProgram2")%></td>
          <td><%=objRS("BPoints2")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherB2")%></td>
          <td><%=objRS("BPoints2")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("BProgram3")%></td>
          <td><%=objRS("BPoints3")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherB3")%></td>
          <td><%=objRS("BPoints3")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("BProgram4")%></td>
          <td><%=objRS("BPoints4")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherB4")%></td>
          <td><%=objRS("BPoints4")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("BProgram5")%></td>
          <td><%=objRS("BPoints5")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherB5")%></td>
          <td><%=objRS("BPoints5")%></td></tr>      
          </table></td>
          
          <td><center><table width="30%"  border="0" cellpadding="5" cellspacing="0"> 
          <tr> <table border="2" cellpadding="5" cellspacing="3" bordercolor="black" bgcolor="black">
          <tr bgcolor="#000000">
          <th colspan="2"><font color="white" face="perpetua titling mt"><b>C</b></font></th>
          <tr bgcolor="silver">
          <th>C Program</th>
          <th>C Points</th></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("CProgram1")%></td>
          <td><%=objRS("CPoints1")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherC1")%></td>
          <td><%=objRS("CPoints1")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("CProgram2")%></td>
          <td><%=objRS("CPoints2")%></td></tr>
          <tr valign="top" bgcolor="white">
          <td><%=objRS("OtherC2")%></td>
          <td><%=objRS("CPoints2")%></td></tr>
          </table></td>     
          </tr> 
          </table>
          </center>
          
          </font>
          </body>
          </html>
          
          
          <%
          objRS.Close
          Set objRS = Nothing
          oConn.Close
          Set oConn = Nothing
          %>

          Comment

          • CroCrew
            Recognized Expert Contributor
            • Jan 2008
            • 564

            #6
            The code you post above, is it from the page "accountpage.as p"?

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

            If LEN(objRS("APro gram1")) > 0 Then

            Comment

            • jerrydigital
              New Member
              • Oct 2008
              • 67

              #7
              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:

              Code:
              <tr valign="top" bgcolor="white"> 
              <td><%=objRS("AProgram1")%></td> 
              <td><%=objRS("APoints1")%></td></tr>
              I enter this code in place of each row(the code directly above):
              Code:
              <% 
                  If (LEN(objRS("AProgram1")) > 0) Then 
                      Response.Write("<tr valign='top' bgcolor='white'>") 
                          Response.Write("<td>" & objRS("AProgram1") & "</td>") 
                          Response.Write("<td>" & objRS("APoints1") & "</td>") 
                      Response.Write("</tr>") 
                  End If 
              %>

              Comment

              • CroCrew
                Recognized Expert Contributor
                • Jan 2008
                • 564

                #8
                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~

                Comment

                • CroCrew
                  Recognized Expert Contributor
                  • Jan 2008
                  • 564

                  #9
                  Hello jerrydigital,

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

                  Code:
                  Response.Write("Post This: [" & objRS("AProgram1") & "]")
                  Response.End
                  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~

                  Comment

                  • jerrydigital
                    New Member
                    • Oct 2008
                    • 67

                    #10
                    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

                    Comment

                    • CroCrew
                      Recognized Expert Contributor
                      • Jan 2008
                      • 564

                      #11
                      Glad to help.

                      CroCrew~

                      Comment

                      Working...