Loans - MySpace Backgrounds - Advertising - Mortgages - Bad Credit Mortgages

PDA

View Full Version : passing string to javascript function from asp


rag84dec
Feb 5th 2008, 8:56 pm
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>")

%>

locdev
Feb 6th 2008, 12:39 am
Escape quotes

response.write("<input type='button' value='Submit' onClick='ChangeAll("""&r&"""')'>")

this code should produce this:

<input type='button' value='Submit' onClick='ChangeAll("value of r")'>