1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

passing string to javascript function from asp

Discussion in 'JavaScript' started by rag84dec, Feb 5, 2008.

  1. #1
    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


    
     <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>")
    
    %>
    
    Code (markup):

     
    rag84dec, Feb 5, 2008 IP
  2. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Escape quotes
    
    response.write("<input type='button' value='Submit' onClick='ChangeAll("""&r&"""')'>")
    
    Code (markup):
    this code should produce this:
    
    <input type='button' value='Submit' onClick='ChangeAll("value of r")'>
    
    Code (markup):
     
    locdev, Feb 5, 2008 IP