JS Quotes

S

scott

Can someone help me with quote syntax? The single quotes with javascript
function are messing me up.

CODE
 
B

Bob Barrows [MVP]

scott said:
Can someone help me with quote syntax? The single quotes with
javascript function are messing me up.

CODE
---------
response.write ""<a href=""javascript:
VerifyDelete1('del-message.asp?fid=" iActiveForumId1 & "&mode=" &
thread & "&tid=" & iId "');">" & "<img src=""images/xsm-delete.gif""
width=""10"" height=""10"" border=""0"" alt=""Delete
Message""></a></td>"


This may be easier:

....
%>
<a href="javascript: VerifyDelete1('del-message.asp?fid=
<%= iActiveForumId1%>
&mode=
<%=thread %>
"&tid=
<%=iId%>
');>
<img src="images/xsm-delete.gif" width="10"
height="10" border="0" alt="Delete Message"></a></td>

However, if you MUST do it in a single response.write, my preference would
be to assign the string to a variable and response.write the variable ... it
makes the code a little cleaner:

<%
dim sHTML
....
sHTML= "<a href=""javascript: " & _
"VerifyDelete1('del-message.asp?fid=" & iActiveForumId1 & _
"&mode=" & thread & "&tid=" & iId & "');"">" & vbcrlf & _
"<img src=""images/xsm-delete.gif"" width=""10"" " & _
"height=""10"" border=""0"" alt=""Delete Message""></a></td>"
....
%>
<html><body>
....
<%=sHTML%>
....

HTH,
Bob Barrows
 
S

scott

thanks again. these quotes get nasty.

Bob Barrows said:
This may be easier:

...
%>
<a href="javascript: VerifyDelete1('del-message.asp?fid=
<%= iActiveForumId1%>
&mode=
<%=thread %>
"&tid=
<%=iId%>
');>
<img src="images/xsm-delete.gif" width="10"
height="10" border="0" alt="Delete Message"></a></td>

However, if you MUST do it in a single response.write, my preference would
be to assign the string to a variable and response.write the variable ...
it makes the code a little cleaner:

<%
dim sHTML
...
sHTML= "<a href=""javascript: " & _
"VerifyDelete1('del-message.asp?fid=" & iActiveForumId1 & _
"&mode=" & thread & "&tid=" & iId & "');"">" & vbcrlf & _
"<img src=""images/xsm-delete.gif"" width=""10"" " & _
"height=""10"" border=""0"" alt=""Delete Message""></a></td>"
...
%>
<html><body>
...
<%=sHTML%>
...

HTH,
Bob Barrows


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
 
S

scott

Bob, can you help me again? I'm at a complete shutdown because of some
stupid quotes. Below in GOOD CODE, I have a mix of ASP/HTML that works. I'm
trying to
convert the GOOD CODE into all ASP, but I'm failing in BAD CODE.

BAD CODE:

sHTML=sHTML & "bgcolor=" & tblcolor & style=""cursor:default;""
onMouseOver="this.bgColor=""'#e6e6e6'"" onMouseOut="this.bgColor='" &
tblcolor & "'"

GOOD CODE:

<%
If sPageType = "forum" Then %>

bgcolor="<%= tblcolor %>" style="cursor:default;"
onMouseOver="this.bgColor='#e6e6e6'" onMouseOut="this.bgColor='<%= tblcolor
%>'"

<% End If %>>
 
G

Giles

"scott" wrote >
GOOD CODE:

<%
If sPageType = "forum" Then %>

bgcolor="<%= tblcolor %>" style="cursor:default;"
onMouseOver="this.bgColor='#e6e6e6'" onMouseOut="this.bgColor='<%=
tblcolor
%>'"

Try (untested!) (on one line)

response.write "bgcolor=""<%= tblcolor %>"" style=""cursor:default;""
onMouseOver=""this.bgColor='#e6e6e6'"" onMouseOut=""this.bgColor='<%=
tblcolor %>'"""

There is a (VBS) HTML-To-String converter at
http://www.verifiedlearning.com/convertscripts.htm

Not bulletproof, but I use it for this common task.
Hope that helps
Giles
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,148
Messages
2,570,838
Members
47,385
Latest member
Joneswilliam01

Latest Threads

Top