PDA

View Full Version : Passing File Name with a Space to Document.Write



dch31969
10-15-2007, 03:44 AM
The following code is crapping out giving me a 'Unterminated String Constant' error when the page loads. When I debug, the offending line is further down the HTML. I have tracked it down to the presence of the spaces in the string. Taking out the spaces eliminates the error. Any ideas?

test = "C:\Documents and Settings"
document.write("<li style='list-style-image:url(xls.ico);'><span onClick=openFile('" & test & "')>Exhibitor Services Schedule</span></li>")

Trinithis
10-15-2007, 05:21 AM
Try

test = "C:\Documents and Settings";
document.write("<li style='list-style-image:url(xls.ico);'><span onclick='openFile(\" & test & \")'>Exhibitor Services Schedule</span></li>")

dch31969
10-15-2007, 11:28 AM
Try

test = "C:\Documents and Settings";
document.write("<li style='list-style-image:url(xls.ico);'><span onclick='openFile(\" & test & \")'>Exhibitor Services Schedule</span></li>")


Its VBScript. Hence no ';' and at then end of the document.write statement.