Forums

Form Javascript stopped working when moved to another server

wmuckell 27 Oct, 2010
Have a form with this code

<div id="contactform" align="center">

  <div id="name">     
    <label for="name-field" class="overlabel">Name</label>
    <input name="name" type="text" id="name-field" tabindex="1" title="name" value="" />
  </div>
   <div id="website">     
    <label for="website-field" class="overlabel">Website</label>
    <input name="website" type="text" id="website-field" tabindex="2" title="website" value="" />
  </div>
   <div id="telephone">     
    <label for="telephone-field" class="overlabel">Tel</label>
    <input name="telephone" type="text" id="telephone-field" tabindex="3" title="telephone" value="" />
  </div>
   <div id="email">     
    <label for="email-field" class="overlabel">Email</label>
    <input name="email" type="text" id="email-field" tabindex="4" title="email" value=""  />
  </div>
  <div id="submit">
<br />
    <input class="button" type="submit" name="send" value="send" tabindex="5" />
  </div>


</div> 



and this form javascript
function initOverLabels () {
  if (!document.getElementById) return;      

  var labels, id, field;

  // Set focus and blur handlers to hide and show 
  // labels with 'overlabel' class names.
  labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {

    if (labels[i].className == 'overlabel') {

      // Skip labels that do not have a named association
      // with another field.
      id = labels[i].htmlFor || labels[i].getAttribute ('for');
      if (!id || !(field = document.getElementById(id))) {
        continue;
      } 

      // Change the applied class to hover the label 
      // over the form field.
      labels[i].className = 'overlabel-apply';

      // Hide any fields having an initial value.
      if (field.value !== '') {
        hideLabel(field.getAttribute('id'), true);
      }

      // Set handlers to show and hide labels.
      field.onfocus = function () {
        hideLabel(this.getAttribute('id'), true);
      }
      field.onblur = function () {
        if (this.value === '') {
          hideLabel(this.getAttribute('id'), false);
        }
      }

      // Handle clicks to label elements (for Safari).
      labels[i].onclick = function () {
        var id, field;
        id = this.getAttribute('for');
        if (id && (field = document.getElementById(id))) {
          field.focus();
        }
      }

    }
  }
}

function hideLabel (field_id, hide) {
  var field_for;
  var labels = document.getElementsByTagName('label');
  for (var i = 0; i < labels.length; i++) {
    field_for = labels[i].htmlFor || labels[i]. getAttribute('for');
    if (field_for == field_id) {
      labels[i].style.textIndent = (hide) ? '-1000px' : '0px';
      return true;
    }
  }
}

window.onload = function () {
  setTimeout(initOverLabels, 50);
}


and this Form CSS
div#contactform {
  position:relative;
  width:100%;
  margin:0px;
}
div#contactform div#name, div#contactform div#website , div#contactform div#telephone, div#contactform div#email {
  position:relative;
  clear:both;
  float:left;
  margin-right:3px;
}

div#contactform input#name-field, div#contactform input#website-field, div#contactform input#telephone-field, div#contactform input#email-field {
  width:10em;
}

div#contactform label.overlabel {
	color:#999;
  }
div#contactform label.overlabel-apply {
	position:absolute;
	top:3px;
	left:25px;
	z-index:1;
	color:#666;
  }
div#contactform div#submit{
	clear:both;
	margin-left: 30px;
}


The script and CSS seem not to be working, when moved to a new server.
GreyHead 27 Oct, 2010
Hi wmuckell,

Your form code all seems to work OK here.

Please post a link to the form so we can take a quick look.

Bob
wmuckell 27 Oct, 2010
<REMOVED>

Form on the right of the screen.

Javascript doesn't appear in code
GreyHead 27 Oct, 2010
Hi wmuckell ,

No, neither the JavaScript or the CSS are being loaded into the page.

Is this Joomla! v 1.5.21? Someone else had a similar report with a recent version.

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
wmuckell 27 Oct, 2010
Using version 1.5.20

I will update, but it worked fine on another server.
GreyHead 27 Oct, 2010
Hi wmuckell,

Just installed on Joomla! 1.5.21 and it looks fine - I'm baffled at the moment.

Bob
wmuckell 27 Oct, 2010
Updates to 1.5.21 no different.

Could there be any php settings stopping this on the new server?
GreyHead 27 Oct, 2010
Hi wmuckell,

PHP - no I don't think so; server security, yes - maybe it only allows js & css from certain folders. Not something I know much about :-(

Bob
wmuckell 27 Oct, 2010
If it helps figure this out. I have just tested it and the javascript form validation is not working either?
GreyHead 27 Oct, 2010
Hi wmuckell,

Yes, none of the ChronoForms script or js files are being loaded :-(

Bob
wmuckell 27 Oct, 2010
Yes, I have another form on the site with no additional js script, but the standard form validation and that is not loading either? Got to be a server thing, but if anything comes to mind. Please let me know.
wmuckell 28 Oct, 2010
FIXED.

I downloaded a copy of the forms and uninstalled the Chrono engine and module. Cleaned the cache. Then restored file and hey presto! Wierd one, but working now and realised how great Chronoforms is, esp this backup function I never used before.

Thanks for help.
GreyHead 28 Oct, 2010
Hi wmuckell,

Good to hear that it's working OK. You are the second user who reported that a re-install fixed a problem like this.

Bob
wmuckell 28 Oct, 2010
Maybe there are some paths entered in the database when the component is installed that do not match on a different server configuration???
GreyHead 28 Oct, 2010
Hi wmuckell,

That's possible, though from what I remember Max uses the JPATH_SITE or JURI::base variables pretty much everywhere to avoid just this kind of problem.

Bob
wmuckell 02 Nov, 2010
Ok, this is happening again. On another site too with Javascript and CSS in addition to the form HTML.

Overnight for some reason the CSS and Javascript stops loading. Uninstalling the component and reinstalling works, but I cannot do this everyday.

Any ideas?
GreyHead 02 Nov, 2010
Hi wmuckell,

No idea - it has to be a site/server related problem. Do you have caching enabled?

Bob
wmuckell 02 Nov, 2010
Nope caching not turned on
wmuckell 03 Nov, 2010
Its happened again today.

The only error on the server is

[Wed Nov 03 09:33:17 2010] [error] [client 220.225.53.171] File does not exist: /home/compare/public_html/templates/beez, referer: /index.php?option=com_chronocontact&Itemid=2

Which is a weird one because I am not using Beez and have deleted the template from the server. Any more ideas?
GreyHead 03 Nov, 2010
Hi wmuckell,

Absolutely no idea, as far as I recall ChronoForms doesn't call any template files.

Bob
wmuckell 04 Nov, 2010
I get this back from my hosting company after this has happened again.

"nothing is interfering or preventing the scripts from loading properly so something must be occurring within the application which we are not able to debug, we are not seeing any errors in the apache logs as well."

This is now happening on two site on the same server, however I have similar setups on other servers and have no issues with the javascript or css not loading itself overnight. Worked fine yesterday after a component reinstall, but this morning same issue.

Can you please give me some ideas on how I could possibly debug this? It there any PHP hacks I can do to try and figure out what is happening on these servers?

Your help is greatly appreciated.
GreyHead 06 Nov, 2010
Hi wmuckell,

I'm sorry, I'm at a loss to suggest anything. There is nothing in ChronoForms that will change the site behaviour from one day to the next :-(

By all means email or PM me the site URL and a SuperAdmin login and I'll take a quick look to see if I can see anything obvious.

Bob
wmuckell 08 Nov, 2010
Eventually figured out. Antimalware on the server thought the Chronoforms was bad and renamed the files!!!!!

Shame the hosting company took so long to release!

Thanks for your help
GreyHead 08 Nov, 2010
Hi wmuckell,

Hmmm . . . that makes sense but it's really not helpful if they don't tell you that they've renamed the files.

If the scanner was ESET/Nod32 then there is a fixed file in the forums that avoids a 'false positive' report. Search on 'trojan' or 'ESET'.

Bob
This topic is locked and no more replies can be posted.