If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Where to use HTML in script?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-19-07, 10:08
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
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
Reply With Quote
  #2 (permalink)  
Old 10-19-07, 16:57
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 10-20-07, 18:08
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
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
Reply With Quote
  #4 (permalink)  
Old 10-22-07, 07:45
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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.
__________________
George
Twitter | Blog

Last edited by gvee; 10-22-07 at 07:54. Reason: Further explanation :-)
Reply With Quote
  #5 (permalink)  
Old 10-22-07, 08:27
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
Quote:
Originally Posted by georgev
(note that this should read <br />)
only for certain DOCTYPEs, george
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #6 (permalink)  
Old 10-22-07, 08:50
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
Quite correct... However the doctype should be for XHTML for the page to be leet
__________________
George
Twitter | Blog
Reply With Quote
  #7 (permalink)  
Old 10-22-07, 09:03
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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.
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #8 (permalink)  
Old 10-22-07, 09:16
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #9 (permalink)  
Old 10-23-07, 18:19
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
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
Reply With Quote
  #10 (permalink)  
Old 10-24-07, 03:28
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #11 (permalink)  
Old 10-24-07, 11:41
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
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
Reply With Quote
  #12 (permalink)  
Old 10-24-07, 14:43
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,143
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
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
Reply With Quote
  #13 (permalink)  
Old 10-24-07, 17:54
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
  #14 (permalink)  
Old 10-25-07, 17:38
Quetzal Quetzal is offline
Registered User
 
Join Date: Feb 2006
Posts: 51
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
Reply With Quote
  #15 (permalink)  
Old 10-27-07, 11:35
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
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
Twitter | Blog
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On