I am trying to store a variable from my database into a JavaScript variable with the code below:
var long = "<%=RecordSet.record.get('GPS - Longitude')%>";
The <%= and %> are tags local to the API for the program i am using which is based on JavaScript and runs JavaScript. When i call this data field from the database:
If data is stored as: 91° 6' 5" W The data will not store in variable "long" because of the " character in the string.
If data开发者_JS百科 is stored as: 91° 6' 5 W The data will be stored fine in variable "long".
I know there is a .php function called "addslashes()" which is supposed to remedy this issue when pulling information from a database. I have tried using the "replace" function on the database call with no luck. Is this possible within JavaScript?
Have you tried using the javascript function 'replace'
string.replace('"', "'");
Or in the php you can use the replace function there
$string=str_replace('"', "'", $string);
The issue has been resolved. It was pertaining to the program i was using. If you are interested here is the link:
http://forums.extensis.com/jforum/posts/list/3695.page
精彩评论