Skip to content
Advertisement

How to set value in the textbox from database that contain a quotation mark in it?

I am using Laravel and I have an update modal. My data is not set on the modal because one of the data contain quotation mark like in the picture below.

My button’s code is like this:

JavaScript

and my javascript code is like this:

JavaScript

And my problem is the Item Name not appear on my textbox <input type="text" class="form-control" id="cart_item_update" readonly> and it is because the data has quotation mark. I tried select the data which not contain quotation mark, and it’s worked well, the data showed up in the text box.

Advertisement

Answer

Since you know that you will be using it inside a javascript call, just replace the ' by ' or replace it with (space) or nothing

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement