View Full Version : calling asp variables inside js
Mhtml
09-15-2002, 10:26 AM
How can I use an asp variable in js?
the variable is ConMessage
and the js is just
if(this.value==' THE ASP VARIABLE ';) {this.value=''}
I need to get the value of the asp variable where it is stated in red...
boywonder
09-15-2002, 02:34 PM
if(this.value=='<%=ConMessage%>') {this.value=''}
Mhtml
09-16-2002, 08:32 AM
doesn't work, keep getting expected ')'
glenngv
09-16-2002, 09:36 AM
make sure the value of the asp variable has no quotes inside.
if you expect ConMessage to have both single and double quotes in its value, you have to replace them with:
<%
'replace single quote with \'
ConMessage = replace(ConMessage,"'","\'")
'replace single quote with \"
ConMessage = replace(ConMessage,"""","\"")
%>
then in your javascript, you can use either single or double quotes in your string delimeter:
if(this.value=='<%=ConMessage%>') {this.value=''}
Mhtml
09-19-2002, 08:13 AM
ahhh, I see...thanks Glenn
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.