Click to See Complete Forum and Search --> : Validate!


hooloovoo24
08-11-2005, 05:16 PM
My pages won't validate (http://validator.w3.org/check?uri=http%3A%2F%2Fwww.cityofpoulsbo.com) because of a calendar script I am using on them. (site: http://www.cityofpoulsbo.com). Here's a sample of the code that is creating problems:

strTable = "<table bgcolor=" & strBGColor1 & " border=" & intTblBorder & " cellpadding=" & intTblCpad & " cellspacing=" & intTblCspc & ">" & VbCrLf &_
"<tr bgcolor=" & strTHColor1 & ">" & VbCrLf

variables:
strBGColor1 = "#ffffff" ' color of table background
strTDColor1 = "#cecece" ' color of default calendar cells
strTDColor2 = "#b5b6c8" ' color of event cells
strTDColor3 = "#aaaaaa" ' color of current day cell
strTHColor1 = "#483d8b" ' color of table header
strTHColor2 = "#483d8b" ' use this if you want 2 header cell colors

intTblBorder = 0 ' table border
intTblCpad = 2 ' cellpadding
intTblCspc = 1 ' cellspacing

strFileName = "../CityCouncil/calendar.asp" ' name of the webpage displaying the calendar
strTip = "Click to see a list of events" ' set to an empty string ("") to disable tool tip

What I need to do is make it so that there are "" around the attribute values (for instance the background color of the table). Any ideas?

silverbullet24
08-11-2005, 05:46 PM
strTable = "<table bgcolor=" & """ & strBGColor1 & """ & " border=" & """ & intTblBorder & """ & " cellpadding=" & """ & intTblCpad & """ & " cellspacing=" & """ & intTblCspc & """ & ">" & VbCrLf &_
"<tr bgcolor=" & """ & strTHColor1 & """ & ">" & VbCrLf

buntine
08-11-2005, 08:02 PM
Just to clarify: In ASP, all special characters can be escaped by doubling them up. So, in a C-based language, you would do this: \". But in BASIC-based you do this: "".

Another way to acheive this with slightly less code (but no benefit, only up to personal taste):

strTable = "<table bgcolor=""" & strBGColor1 & """ border=""" & intTblBorder & """ cellpadding=""" & intTblCpad & """ cellspacing=""" & intTblCspc """>" & VbCrLf & _
"<tr bgcolor=""" & strTHColor1 & """>" & VbCrLf

The reason we need three quotes is because one of them actually tells VBScript that the current string literal is being terminated.

Regards.