1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

passing string to javascript function from asp

Discussion in 'JavaScript and AJAX' started by rag84dec, Feb 6, 2008.

  1. rag84dec

    rag84dec New Member

    Joined:
    Jul 17, 2007
    Messages:
    49
    Likes Received:
    0
    Trophy Points:
    0
    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>")
     
     %>
     
     
    Last edited by a moderator: Feb 6, 2008
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    Probably the code should look like this,

    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>")
    
    %>
    
     

Share This Page