passing string to javascript function from asp

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rag84dec
    New Member
    • Mar 2007
    • 100

    passing string to javascript function from asp

    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:
     <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>")
    
    %>
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    You haven't closed the button tag and since you're mixing quotes, try something like:[code=asp]response.write( "<input type='button' value='Submit' onClick='Change All("""&r&""")' >")
    [/code]

    Comment

    Working...