Hi, I'm relatively new to JS. I have a function that pops up a window, then from the popup a user will select some text. The text will then be placed in a <textarea> tag in the opener as the popup closes. The (very simple) function is:
function put_back(form,field,text) {
opener.document.forms[form].elements[field].value = text;
self.close();
}
The function is called via an anchor tag. It works great until the text I'm sending back to the opener has any single quotes in it. I imagine I have to escape these characters. The text is generated on the fly by database queries, so I suppose I need a function to do this.
Am I going in the right direction? If so, does anyone know of a function that will parse a a string and escape the appropriate characters? If not, what should I be doing?
Thanks in advance,
Kerr
function put_back(form,field,text) {
opener.document.forms[form].elements[field].value = text;
self.close();
}
The function is called via an anchor tag. It works great until the text I'm sending back to the opener has any single quotes in it. I imagine I have to escape these characters. The text is generated on the fly by database queries, so I suppose I need a function to do this.
Am I going in the right direction? If so, does anyone know of a function that will parse a a string and escape the appropriate characters? If not, what should I be doing?
Thanks in advance,
Kerr