Page 1 of 1

Adding Javascript to page corrupts form template

Posted: Thu Nov 27, 2008 6:25 pm
by ronaldm
I have added a small piece of JavaScript to a certain page on our website. This JavaScript should have stripped a certain querystringparameter from the url (used to track campaigns in an external CRM system), so it can be passed trough a form to a thank you page.

Code: Select all

<__script__ type="text/javascript">

function getQuerystring(key, default_)
{
  if (default_==null) default_="";
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
} 

</__script>
The code was tested on a site which didn't use CMSMS, and there everything worked fine, so we deployed it to our own website.
This piece of code was hard coded in a couple of pages (not in the template for that page) which includes a form made by the formbuilder. When I looked at the page, a couple of errors appeared stating that there were some \'s in the form which obviously caused errors.

After removing the code from the page, the problem still persisted and I tried to recreate the form (both by uploading an xml file with the code from a working form, as well as recreating a form from scratch). However, every time I save the form, the form template is being screwed up. Everytime I save a form, multiple \'es are being added to the form template in CMSMS.

I already tried to create a form from scratch, using an xml file of a form which is still working fine, but still this problem persists. Also when using different computers (to avoid caching) and also different locations (both at work as wel at home). It seems to me, that something terribly has been changed in the backend of the CMS

Does anyone have a clue what has happened and what we can do to solve this, as it really looks like that our CMS is screwed....

Re: Adding Javascript to page corrupts form template

Posted: Thu Nov 27, 2008 7:10 pm
by Dee

Re: Adding Javascript to page corrupts form template

Posted: Thu Nov 27, 2008 7:15 pm
by ronaldm
I did. If it was just a "regular" JavaScript issue, the form should have been working fine again when I removed the JavaScript from the page. However, it is persistent and keeps on changing the form template (by adding backslashes) in CMSMS......

The JavaScript code I added to the page, causes this in the form template:

Code: Select all

Below, you\'ll find the "standard CSS template" for displaying FormBuilder Forms

   You can edit it to make your form layout look any way you\'d like.

   To make the form work, you\'ll need to always include the {$hidden} and {$submit}

   tags.
All single and double quotes are being escaped, not only in comments, but also in the code for the template. Pasting a new "clean" template does not help. As soon as I hit the save button, everything is messed up again... ???