Menu
Hi, I would like to know how to pass strings that contain the ‘ sign in html when using javascript functions.
I have the editElement function in javascript that takes in 3 arguments in php. It so happens some products (in this case under the $product” variable) contain an ‘ in their name. I call the function when a button is clicked via the onclick event.
onClick=’editElement(1,2,”$product”)’
so what happens is when a product like “Jake’s Soup” is entered.
the command becomes:
onClick=’editElement(1,2,”Jake’s Soup”)’
which causes an error because of the ‘ in the “”.
How do you escape this character in javascript to make it work.
Thanks.