1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

passing string to javascript function from asp

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

  1. rag84dec

    rag84dec New 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:
      <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

    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