Welcome to the dBforums forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

If you prefer not to see double-underlined words and corresponding ads, place your cursor
here for ContentLink opt out.

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, 09: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, 18:05
rhs98 rhs98 is offline
Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 440
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 18:08.
Reply With Quote
  #3 (permalink)  
Old 04-26-03, 00: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, 08:41
rhs98 rhs98 is offline
Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 440
erm doubling works too...
Reply With Quote
  #5 (permalink)  
Old 04-26-03, 10: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, 09:03
rhs98 rhs98 is offline
Moderator
 
Join Date: Feb 2002
Location: Hampshire, UK
Posts: 440
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On