I don't think that this issue would be related to the location you have the files in. I think it is just because of the double quotes being interpreted by the browser under certain conditions.
The code that you highlighted in red is exactly where this should be done. The code should look very similar on both pages. Once you wrap the function around the value it should preserve the quotes as their html entities, this way the browser will not display them incorrectly. Please give this a try on this value and let us know if there are any problems.