I have a Javascript function (named insert_formatText) which inserts text into a specified textarea. This function takes 4 parameters: - opentag (the open tag) - closetag (the close tag) - formid (id-attribute value of the form) - elementid (id-attribute value of the textarea)
My function works very well except for when you set opentag as """ and closetag as """. In that case, it simply breaks.
<a href="javascript:;" onclick="insert_formatText('"""', '"""', 'foo', 'bar');">INSERT TRIPLE-QUOTES</a>
Extra Detail
I actually use PHP to loop through an array containing the opentag and closetag values as a key => value pair. In the loop, I pass those values to a function:
function editorButton($pre, $suf, $fid, $eid, $label){
$str = <<<EOT
<a href="javascript:;" onclick="insert_formatText('$pre', '$suf', '$fid', '$eid');">$label</a>
EOT;
return $str;
}
So my question: is there anyway to get this to work for double-quotes without much changing? Or will I have to find a different method to generate these buttons?