By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,454 Members | 3,133 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,454 IT Pros & Developers. It's quick & easy.

passing string to javascript function from asp

100+
P: 100
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


Expand|Select|Wrap|Line Numbers
  1.  <script language="JavaScript">
  2. function ChangeAll(f)
  3. {
  4.  
  5.     alert(f);
  6. }
  7.  
  8. </script>
  9.  
  10. <%
  11.  
  12.  
  13.  
  14. r="here"
  15. response.write("<form method='post'>")
  16. response.write("<input type='button' value='Submit' onClick='ChangeAll(''"&r&"'')'    ")
  17. response.write("</form>")
  18.  
  19. %>
  20.  
Feb 6 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
You haven't closed the button tag and since you're mixing quotes, try something like:
Expand|Select|Wrap|Line Numbers
  1. response.write("<input type='button' value='Submit' onClick='ChangeAll("""&r&""")'>")
  2.  
Feb 6 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.