Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JavaScript call in ASP 1

Status
Not open for further replies.

blueindian1

Programmer
Apr 24, 2001
150
US
ladies and gents,

i KNOW this is a dumb question, but i still can't remember...

how do you call a JavaScript Function that requires a string parameter within ASP?

for instance:
Code:
response.Write &quot;<input type='button' onClick='someFunction(string)>&quot;

what i need to know is...how do i identity the string as a literal? singal tics nor double tics work.

thanks,

rich
 
Did you say, &quot;The technique escaped me?&quot;
Code:
response.Write &quot;<input type='button' onClick='someFunction(\&quot;string\&quot;)'>&quot;
[\code]
 
Well I don't have the answer but I do know that your syntax is incorrect here...You are missing a single quote. The missing quote is in red.
response.Write &quot;<input type='button' onClick='someFunction(string)'>&quot;
Sera
I often believe that...
My computer is possessed!
 
try this:
response.Write &quot;<input type='button' onClick='someFunction(&quot; & string & &quot;)'>&quot;
 
Or:
<input type=&quot;button&quot; onClick=&quot;someFunction('<%= string %>')&quot;> [pc3]
 
Escapes, fun stuff. rac's should work just fine, the rest will write your string into the javascript function just fine, but the javascript won't see it as a string due to the lack of quotes. Another way similar to rac's to do this would be to apply the escapes in the ASP:
Code:
response.Write &quot;<input type=&quot;&quot;button&quot;&quot; onClick=&quot;&quot;someFunction('string')&quot;&quot;>&quot;
Thus we have escaped the double quotes in ASP
An easier (sorry, quick and dirty is my phrase for the week) way to do this is to escape out of the ASP:
Code:
%><input type=&quot;button&quot; onClick=&quot;someFunction('string')&quot;><%
giving you the same exact results as my previous statement.

if you need to replace string with ASP than:
firstway:
Code:
response.Write &quot;<input type=&quot;&quot;button&quot;&quot; onClick=&quot;&quot;someFunction('&quot;&string&&quot;')&quot;&quot;>&quot;
secondway:
Code:
%><input type=&quot;button&quot; onClick=&quot;someFunction('<%=string%>')&quot;><%

-Tarwn
 
OR

response.Write &quot;<input type=&quot;&quot;button&quot;&quot; onClick=&quot;JavaScript:someFunction('<% = string%>')&quot;
 
:)
I know what you meant so I hope you don't mind if I add some quotes:
response.Write &quot;<input type=&quot;&quot;button&quot;&quot; onClick=&quot;&quot;JavaScript:someFunction('<% = string%>')&quot;&quot;&quot;

-Tarwn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top