Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Join Date
    Feb 2006
    Posts
    72

    Unanswered: Where to use HTML in script?

    Hello

    I have a .asp page which shows me what is in my mS Access 2000 database, such as:

    Fullname = Ma Stapleton
    Email = marialopez@whatever.com
    Business = None
    Country = Argentina
    Message = Hiya
    Date = 10/3/2007 9:11:42 AM

    The type is in courier and somewhat dull, and I wonder how I could make it more presentable, using a different font, style, and colour.

    This is the relevant part of the script behind the show.asp page (above):

    While NOT TBL.EOF
    Response.Write("Fullname = " & TBL("fullname") & "<br>")
    Response.Write("Email = " & TBL("email") & "<br>")
    Response.Write("Business = " & TBL("business") & "<br>")
    Response.Write("Country = " & TBL("country") & "<br>")
    Response.Write("Message = " & TBL("message") & "<br>")
    Response.Write("Date = " & TBL("date") & "<br><br><br>")

    TBL.MoveNext
    Wend
    TBL.Close

    How (and where) would I introduce the HTML which I need in order to make my page a little more presentable?

    Many thanks.

    Quetzal

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    You hav e already introduced html...
    Code:
    <br>
    (note that this should read <br />)

    Anything that is written (Response.write) is written to the source and THEN it is rendered on the client's machine. You can think of this as the source code being written dynamically.

    Have a go with this
    Code:
    Response.Write("<table border="1">")
    
    While NOT TBL.EOF
    
      Response.Write("<tr><td>Fullname</td><td>" & TBL("fullname") & "</td></tr>")
      Response.Write("Email</td><td>" & TBL("email") & "</td></tr>")
      Response.Write("<tr><td>Business</td><td>" & TBL("business") & "</td></tr>")
      Response.Write("<tr><td>Country</td><td>" & TBL("country") & "</td></tr>")
      Response.Write("<tr><td>Message</td><td>" & TBL("message") & "</td></tr>")
      Response.Write("<tr><td>Date</td><td>" & TBL("date") & "</td></tr>")
      Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    
      TBL.MoveNext
    Wend
    
    TBL.Close
    
    Response.Write("<table>")
    And www.w3schools.com is always a good reference. Example :http://w3schools.com/asp/showasp.asp...emo_formatting


    Hope this helps,
    George

    P.S. I'm very rusty on my ASP and this is written without compiling - so it might not work off the bat
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2006
    Posts
    72
    Hello George

    Very many thanks for your post.

    You have shown me, at least, where the HTML code goes alongside the ASP.

    However, I am getting the following error:

    Microsoft VBScript compilation error '800a03ee'

    Expected ')'

    /showDetails.asp, line 20

    Response.Write("<table border="1">")
    -------------------------------^

    Any ideas why I might be getting this?

    Thank you again.

    Quetzal

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    That should read:
    Code:
    Response.Write("<table border='1'>")
    Note the use of double and single quotes.
    The browser writes what is contained the the double quotes so in the previous (incorrect) piece of code
    Code:
    Response.Write("<table border="1">")
    I have highlighted the pairs of quotes that go together. You will now notice that the 1 is outside of the quotes - which is why the service reported a script error.

    The corrected example at the top of this post shows how the single quotes are nested (contained) within the doubles which means we have no stray characters outside of our write command.
    Last edited by gvee; 10-22-07 at 08:54. Reason: Further explanation :-)
    George
    Home | Blog

  5. #5
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    (note that this should read <br />)
    only for certain DOCTYPEs, george
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quite correct... However the doctype should be for XHTML for the page to be leet
    George
    Home | Blog

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by georgev
    the doctype should be for XHTML
    no, it should not

    internet explorer cannot handle xhtml correctly at all

    if your server doesn't serve xhtml as xml then it is just serving it up as html, in which case every little xhtml peccadillo like <br /> instead of <br> is merely affectation

    please see XHTML vs HTML FAQ (this is a must read, as well as the url in the excerpt below)...
    Is serving XHTML as text/html harmful?
    In 2002 Ian Hickson published an article labelled Sending XHTML as text/html Considered Harmful. It has been criticised by many XHTML proponents, but it should be required reading for anyone who is going to use XHTML markup.
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  8. #8
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Slight misquote but fair enough. I was ignorant to these issues (in some respects I still am until I find time to read the whole article) - My XHTML development was learnt in the classroom; hence the gaps in knowledge regarding issues like these

    I didn't realise that IE, even 7.0 does not support XHTML! That's just another missing/non-standard piece of MS magic
    George
    Home | Blog

  9. #9
    Join Date
    Feb 2006
    Posts
    72
    Sorry George

    No luck.

    I am getting the following error:

    Unterminated string constant

    /showDetails.asp, line 29

    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>
    -------------------------------------------------------^

    I have tried adding a simple </TABLE> tag to it, but get this:

    Unterminated string constant

    /showDetails.asp, line 29

    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>
    ---------------------------------------------------------------^

    At the moment, the complete code is:

    <%

    TBL.Open "Enquiries" ,DB

    Response.Write("<table border='1'>")

    While NOT TBL.EOF
    Response.Write("<tr><td>Fullname</td><td>" & TBL("fullname") & "</td></tr>")
    Response.Write("Email</td><td>" & TBL("email") & "</td></tr>")
    Response.Write("<tr><td>Business</td><td>" & TBL("business") & "</td></tr>")
    Response.Write("<tr><td>Country</td><td>" & TBL("country") & "</td></tr>")
    Response.Write("<tr><td>Message</td><td>" & TBL("message") & "</td></tr>")
    Response.Write("<tr><td>Date</td><td>" & TBL("date") & "</td></tr>")
    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>

    TBL.MoveNext
    Wend
    TBL.Close

    Response.Write("<table>")

    DB.Close

    Set DB = Nothing
    Set TBL = Nothing

    %>

    after I added the </TABLE> tag on the end of:

    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr></table>

    in the final Response.Write row.

    Sorry to keep bothering you!

    Quetzal

  10. #10
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by georgev
    P.S. I'm very rusty on my ASP and this is written without compiling - so it might not work off the bat
    Code:
    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>")
    Note the missing end quote and bracket!

    www.w3schools.com/asp/default.asp
    Check out w3schools.com for help - you'll find it incredibly useful!
    George
    Home | Blog

  11. #11
    Join Date
    Feb 2006
    Posts
    72

    Item not found

    Hello George

    Thanks again for getting back to me and for providing the W3 schools link.

    I have downloaded a couple of pages, notably those concerned with formating text with HTML tags in ASP (which I undoubtedly need).

    Unfortunately, however, my script does not work. I am getting the following:

    ADODB.Recordset error '800a0cc1'
    Item cannot be found in the collection corresponding to the requested name or ordinal.

    /showDetails.asp, line 23

    At the risk of sounding boring, this is what I have so far:

    <%
    Dim DB, TBL
    Set DB = Server.CreateObject("ADODB.Connection")
    Set TBL = Server.CreateObject("ADODB.RecordSet")
    DB.Mode = adModeReadWrite

    DB.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\folder\folder.com\folder\onForm.md b;"



    TBL.Open "Enquiries" ,DB

    Response.Write("<table border='1'>")

    While NOT TBL.EOF
    Response.Write("<tr><td>Fullname</td><td>" & TBL("fullname") & "</td></tr>")
    Response.Write("Email</td><td>" & TBL("email") & "</td></tr>")
    Response.Write("<tr><td>Business</td><td>" & TBL("business") & "</td></tr>")
    Response.Write("<tr><td>Country</td><td>" & TBL("country") & "</td></tr>")
    Response.Write("<tr><td>Message</td><td>" & TBL("message") & "</td></tr>")
    Response.Write("<tr><td>Date</td><td>" & TBL("date") & "</td></tr>")
    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>")

    TBL.MoveNext
    Wend
    TBL.Close

    Response.Write("<table>")

    DB.Close

    Set DB = Nothing
    Set TBL = Nothing

    %>

    Cheers

    Quetzal

  12. #12
    Join Date
    Feb 2004
    Location
    New Zealand
    Posts
    1,424
    Provided Answers: 8
    have a look @ ASP101.com they have some good idea
    hope this help

    See clear as mud


    StePhan McKillen
    the aim is store once, not store multiple times
    Remember... Optimize 'til you die!
    Progaming environment:
    Access based on my own environment: DAO3.6/A97/A2000/A2003/A2007/A2010
    VB based on my own environment: vb6 sp5
    ASP based on my own environment: 5.6
    VB-NET based on my own environment started 2007
    SQL-2005 based on my own environment started 2008
    MYLE
    YOUR PASSWORD IS JUST LIKE YOUR TOOTHBRUSH DON'T SHARE IT.

  13. #13
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Code:
    Response.Write("<table border='1'>")
    
    While NOT TBL.EOF
    Response.Write("<tr><td>Fullname</td><td>" & TBL("fullname") & "</td></tr>")
    Response.Write("Email</td><td>" & TBL("email") & "</td></tr>")
    Response.Write("<tr><td>Business</td><td>" & TBL("business") & "</td></tr>")
    Response.Write("<tr><td>Country</td><td>" & TBL("country") & "</td></tr>")
    Response.Write("<tr><td>Message</td><td>" & TBL("message") & "</td></tr>")
    Response.Write("<tr><td>Date</td><td>" & TBL("date") & "</td></tr>")
    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>")
    
    TBL.MoveNext
    Wend
    TBL.Close
    
    Response.Write("<table>")
    Mistakes highlighted above.

    Can you provide some sample data from the table/query you are populating this information with?
    George
    Home | Blog

  14. #14
    Join Date
    Feb 2006
    Posts
    72
    Hello George

    I have made the correction. I now have this:

    <%
    Dim DB, TBL
    Set DB = Server.CreateObject("ADODB.Connection")
    Set TBL = Server.CreateObject("ADODB.RecordSet")
    DB.Mode = adModeReadWrite

    DB.Open "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\folder\site\folder\onForm.mdb;"



    TBL.Open "Enquiries" ,DB

    Response.Write("<table border='1'>")

    While NOT TBL.EOF
    Response.Write("<tr><td>Fullname</td><td>" & TBL("fullname") & "</td></tr>")
    Response.Write("<tr><td>Email</td><td>" & TBL("email") & "</td></tr>")
    Response.Write("<tr><td>Business</td><td>" & TBL("business") & "</td></tr>")
    Response.Write("<tr><td>Country</td><td>" & TBL("country") & "</td></tr>")
    Response.Write("<tr><td>Message</td><td>" & TBL("message") & "</td></tr>")
    Response.Write("<tr><td>Date</td><td>" & TBL("date") & "</td></tr>")
    Response.Write("<tr><td>&nbsp;</td><td>&nbsp;</td></tr>")

    TBL.MoveNext
    Wend
    TBL.Close

    Response.Write("</table>")

    DB.Close

    Set DB = Nothing
    Set TBL = Nothing

    %>

    Unfortunately,

    I get this:

    ADODB.Recordset error '800a0cc1'
    Item cannot be found in the collection corresponding to the requested name or ordinal.

    Thank you again for your all your efforts and time.

    Steve

  15. #15
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Hey Steve,
    The error message suggests that you are requesting data from columns that don't exist in the recordset.
    For example if my recordset contained the following
    Code:
    SELET firstname, dateOfBirth
    FROM  people
    And we asked it for surnames, then we'd get the error you are having!

    If I were you I'd be checking to see if any data was being returned at all
    Code:
    TBL.Open "Enquiries" ,DB
    Response.Write(TBL(1))
    TBL.Close
    If you're sure it's returning data then add other ordinals i.e.
    Code:
    Response.Write(TBL(2))
    Note that we're not using the .MoveNext command as we simply want to test if there is any data at all by returning a single record.

    You could even test each single row on it's own!

    Give it a go and report back how you get on
    George
    Home | Blog

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •