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 > javascript syntax in ASP

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-25-03, 08:58
am328 am328 is offline
Registered User
 
Join Date: Mar 2003
Location: East Grinstead ,UK
Posts: 19
javascript syntax in ASP

CAn some one help me out with this javascript (ahh!!)
This is the line :

Response.write('<A HREF="javascript:newGuidanceWindow(qmsadditionalin fo.asp?doc_id='+ escape(d1.data[i].doc_id)+')">');

This is the function that i'm calling:

function newGuidanceWindow(newWin,name, features) {

newWin =window.open( newWin, 'my_window','toolbar=no,titlebar=no,location=no,di rectories=no,status=no,menubar=no,scrollbars=no,re sizable=yes,copyhistory=no,width=300,height=300');
}
</script>

I know that the function works outside the <% %> syntax of ASP. Can you tell me what I'm doing wrong?
Reply With Quote
  #2 (permalink)  
Old 04-25-03, 17:05
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
You should use " not ' as a string delimter, you also need to double any which you actually want in the string.

i.e.

Code:
response.write("hello")
writes
Quote:
hello
Code:
response.write("hello ""this is a test""....")
writes
Quote:
hello "this is a test"....
easiest way if you have trouble is to just break out of the ASP

Code:
blah blah
%>
<A HREF="java script:newGuidanceWindow(qmsadditionalinfo.asp?doc_id=<%=escape(d1.data[i].doc_id)%>)">
<%
some more code
or the other way (like your doing now);
Code:
response.write "<A HREF=""java script:newGuidanceWindow(qmsadditionalinfo.asp?doc_id=" & escape(d1.data[i].doc_id) & ")"">"
hope this makes sense...

Last edited by rhs98; 04-25-03 at 17:08.
Reply With Quote
  #3 (permalink)  
Old 04-25-03, 23:39
duckworth duckworth is offline
Registered User
 
Join Date: Apr 2003
Location: NY
Posts: 3
Re: javascript syntax in ASP

If you are using javascript on the server then either double or single quotes as a delimiter is fine. You esape them using a backslash and not by doubling them:


Response.Write("hello \"this is a test\"....")

What is the error you are recieving?


-John lemp
Reply With Quote
  #4 (permalink)  
Old 04-26-03, 07:41
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
erm doubling works too...
Reply With Quote
  #5 (permalink)  
Old 04-26-03, 09:18
duckworth duckworth is offline
Registered User
 
Join Date: Apr 2003
Location: NY
Posts: 3
Then why does this:

<%@ Language=Javascript %>
<%
Response.write("hello ""this is a test""....") ;
%>

Result in this:

Error Type:
Microsoft JScript compilation (0x800A03EE)
Expected ')'
/test.asp, line 3, column 23
Response.write("hello ""this is a test""....") ;
----------------------^
Reply With Quote
  #6 (permalink)  
Old 04-27-03, 08:03
rhs98 rhs98 is offline
Super Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 441
Becuase I was talking about VBScript....
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