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,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    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>")
    
    %>
    
     
  3. Ami Desai

    Ami Desai Member

    Joined:
    Jan 5, 2017
    Messages:
    42
    Likes Received:
    17
    Trophy Points:
    8
    Location:
    Ahmedabad
    Home Page:
    http://www.ifourtechnolab.com/
    Hi,

    Check this
    Instead try following code
    Code:
    <input type='button' value='Submit' onClick='ChangeAll("value of r")'>
    Thanks
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice