Date:  03/21/2004 09:55:50 AM Msg ID:  001899
From:  FoxWeb Support Thread:  001892
Subject:  Re: Simple question
You need to use the following:
 
<a href="javascript:getme('<%Server.JSEscape(alltrim(agency))%>')"> id </a>

FoxWeb Support Team
support@foxweb.com email

Sent by Richard on 03/20/2004 05:49:13 PM:
THANKS AGAIN FOR YOUR QUICK RESPONSE
 
Thing are working ok but with this exception let me go into more detail
 
<script language= "javascript" type= "text/javascript">
function getme(getit) {
alert(getit)
}
 
 
 
<Form name="myform">
 
<a href=javascript:getme("<%alltrim(agency)%")> id </a>
</form>
 
 this works ok reading data from my database but if their is a break in the text like "this is a test" it  comes up with a Java error on the bottom of my browser screen javascript:getme("this       but if the data has only a single string like "test" it says Javascript.getme("test") and it works ok
What the heck am I missing I know it is something simple  thanks again
 
Sent by FoxWeb Support on 03/20/2004 11:27:11 AM:
Oops, sorry for the misinformation.  You actually need to enclose the string in quotes, like so:
 
alert('<%=data%>')
 
Another problem is that the value returned by data may also contain quotes, which would confuse the browser.  To get around this problem you must escape special characters, using the Server.JSEscape method:
 
alert('<%=Server.JSEscape(data)%>')

FoxWeb Support Team
support@foxweb.com email

Sent by Richard on 03/19/2004 11:12:10 PM:
Thanks for your quick response that worked but I found a little problem if I am passing a value like "this is a test" I get a error it appears to be because of spaces in the text if  it is continuious text it's ok I tried using alltrim but this made no difference. Thanks for your help
Sent by FoxWeb Support on 03/19/2004 10:10:39 PM:
If you want to evaluate the expression data and display it in a JavaScript alert box, then you need to use the following syntax:
 
alert(<%=data%>)

FoxWeb Support Team
support@foxweb.com email

Sent by Richard on 03/19/2004 03:05:11 PM:
I am having trouble passing a database values to a function so I am using the alert as a example of the code  what is the problem with alert(<%data%>) I get a error saying  unrecognized command verb. The database is open  what am I forgetting? Thanks