passing string to javascript function from asp

rag84dec's Avatar, Join Date: Jul 2007
Go4Expert Member
Hi,
i tried the following to use a string from asp code in javascript but it didnt work....please tell me how to pass a string to a javascript


Code: ASP
<script language="JavaScript">
 function ChangeAll(f)
 {
     
     alert(f);
 }
 
 </script>
 
 <%
 
 
 
 r="here"
 response.write("<form method='post'>")
 response.write("<input type='button' value='Submit' onClick='ChangeAll(''"&r&"'')'    ")
 response.write("</form>")
 
 %>

Last edited by pradeep; 6Feb2008 at 09:56.. Reason: Code Block
0
pradeep's Avatar, Join Date: Apr 2005
Team Leader
Probably the code should look like this,

Code: ASP
<script language="JavaScript">
function ChangeAll(f)
{
    alert(f);
}

</script>

<%



r="here"
response.write("<form method='post'>")
response.write("<input type='button' value='Submit' onClick='ChangeAll("""&r&""")' ")
response.write("</form>")

%>