response.write a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mispel
    New Member
    • Mar 2008
    • 2

    response.write a table

    I have a problem when trying to display a table as part of an if else statement. The error that I get is the following:

    Error Type:
    Microsoft VBScript compilation (0x800A03EA)
    Syntax error
    /helpdesk/trackedissue.as p, line 154
    else response.Write <table width="599" border="0" align="center">


    The code is:

    <%
    if isnull(checksta tus.Fields.Item ("solution").Va lue) then response.write "Sorry, this issue has not been resolved yet. Please try tracking later."
    else response.write <table width="599" border="0" align="center">
    <tr>
    <td align="left" width="128">Sol ution:</td>
    <td width="161" align="left">(t rackingissue.Fi elds.Item("solu tion").Value)</td>
    <td width="79"></td>
    <td width="199"></td>
    </tr>
    </table>
    end if
    %>

    I am a starter in asp programming, I would appreciate your help. I am using Dreamweaver cs3.

    Thx in adv.
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Try to write the response.write statement like this :
    e.g.

    Code:
     response.write("<table width="599" border="0" align="center">")
    Originally posted by mispel
    I have a problem when trying to display a table as part of an if else statement. The error that I get is the following:

    Error Type:
    Microsoft VBScript compilation (0x800A03EA)
    Syntax error
    /helpdesk/trackedissue.as p, line 154
    else response.Write <table width="599" border="0" align="center">


    The code is:

    <%
    if isnull(checksta tus.Fields.Item ("solution").Va lue) then response.write "Sorry, this issue has not been resolved yet. Please try tracking later."
    else response.write <table width="599" border="0" align="center">
    <tr>
    <td align="left" width="128">Sol ution:</td>
    <td width="161" align="left">(t rackingissue.Fi elds.Item("solu tion").Value)</td>
    <td width="79"></td>
    <td width="199"></td>
    </tr>
    </table>
    end if
    %>

    I am a starter in asp programming, I would appreciate your help. I am using Dreamweaver cs3.

    Thx in adv.

    Comment

    • DrBunchman
      Recognized Expert Contributor
      • Jan 2008
      • 979

      #3
      Originally posted by shweta123
      Hi,

      Try to write the response.write statement like this :
      e.g.

      Code:
       response.write("<table width="599" border="0" align="center">")
      This code will give you an error because the double quotes around the style settings will terminate the string. Use single quotes inside a response.write statement to surround styles & properties. e.g:
      Code:
      response.write "<table width='599' border='0' align='center'>"
      Hope this helps,

      Dr B

      Comment

      • mispel
        New Member
        • Mar 2008
        • 2

        #4
        After posting, I tried again. And it worked like this:

        Response.Write "<table width=" & "599" & "align=" & "center" & " border=" & "0" & "></table>"
        And the whole code to create the table must be on the same line.
        I had to create a large table so, it was hell of a job.

        Thx for your help anyway.

        Mayberly.

        Comment

        • DrBunchman
          Recognized Expert Contributor
          • Jan 2008
          • 979

          #5
          Mispel,

          Good job on geting it working although some of what you've done above is unneccessary. Are you aware of the rules on including quotation marks inside a string? To do so you use double quotation marks so you could write your line above like this:
          Code:
          Response.Write "<table width=""599"" align=""center"" border=""0""></table>"
          Or you could, as I did before, write it using single quotation marks:
          Code:
           
          Response.Write "<table width='599' align='center' border='0'></table>"
          Which I think makes it look neater when reading through the code.

          I'm afraid to say that you also had no need to write the whole table on the same line! This:
          Code:
           
          Response.Write "<table width='599' align='center' border='0'>"
          Response.Write "<tr>" 
          Response.Write "<td>Hello World!</td>"
          Response.Write "</tr>"
          Response.Write "</table>"
          Is exactly the same as:
          Code:
          Response.Write "<table width='599' align='center' border='0'><tr><td>Hello World!</td></tr></table>"
          As you can see the first example is far easier to read than the second.

          I hope this helps. Let us know if you have any more problems.

          Dr B

          Comment

          Working...