There seems to be a couple of issues with the code. Firstly, you can avoid using the Response.Write
s in most cases by using inline field values with the <%= %>
tags. They are a shorthand form of Response.Write
, writing the contents of a variable, property or function to the point where they occur. In your case, you could substitute:
Response.Write "<td WIDTH='6%' VALIGN='TOP' ALIGN='CENTER' bgcolor = " & ObjDic(elem).clrPreExisting & ">" & vbCRLF
Response.Write "<a href = ""javascript:alert("objDic(elem).critRow")""><font size='2' face='Arial' color='#000000'>" & ObjDic(elem).Get_PreExistingVal(RunningTotal.PreExisting) & "</font></a>" &vbCRLF
Response.Write "</td>" & vbCRLF
...with...
<td WIDTH='6%' VALIGN='TOP' ALIGN='CENTER' bgcolor = '<%= ObjDic(elem).clrPreExisting %>'>
<a href = "javascript:alert('<%= objDic(elem).critRow %>')"><font size='2' face='Arial' color='#000000'>
<%= ObjDic(elem).Get_PreExistingVal(RunningTotal.PreExisting) %>
</font></a>
</td>
Please, please take out all of the inline formatting and replace it with styling classes...
<style>
.cellClass {width: 6%; text-align: center; vertical-align: top;}
.cellClass a {font-size: 2; font-family: arial; color: black;}
</style>
...
...
<td class="cellClass" bgcolor = "<%= ObjDic(elem).clrPreExisting %>">
<a href = "javascript:alert('<%= objDic(elem).critRow %>')">
<%= ObjDic(elem).Get_PreExistingVal(RunningTotal.PreExisting) %>
</a>
</td>
I would also recommend sticking to one form of quotation marks. You use several different ones to identify your attributes, including "
, '
, ""
and even none. When I apply values to attributes I always use double speech marks in Classic ASP.
JavaScript is slightly different, though I still use double speech marks to specify the assignment to the attribute, speech marks within the JavaScript code are usually apostrophes ('
):
<a href="javascript:alert('Use single speech marks in strings.');">Click me</a>
In VBScript strings you should escape speech marks by doubling them, so...
Response.Write("Paul said: ""Use double speech marks in strings"".")
Finally, your code is slightly wrong, if you want it to work as is. Try this instead:
Response.Write "<td WIDTH='6%' VALIGN='TOP' ALIGN='CENTER' bgcolor = " & ObjDic(elem).clrPreExisting & ">" & vbCRLF
Response.Write "<a href = ""javascript:alert(" & objDic(elem).critRow & ")""><font size='2' face='Arial' color='#000000'>" & ObjDic(elem).Get_PreExistingVal(RunningTotal.PreExisting) & "</font></a>" &vbCRLF
Response.Write "</td>" & vbCRLF
Notice your JavaScript in the middle line - it's missing the concatenation characters (&
) before and after the property value.