• Hello group, I have an issue with JS on specifically the contact us pages or Contact 7 form pages in our website. Using Firefox error console I can see an error on the page which I assume will keep the banners from dropping down, the widgets from loading, and contact form from sending emails. I am not a JS coder so would love some input from the group. The function is below. The specific call is: if (id.length == 0 && name.length != 0) {

    http://gridone.us.com/contact-us

    function InitMisc() {
      $j('#content input, #content textarea').each(function(index) {
        var id = $j(this).attr('id');
        var name = $j(this).attr('name');
        if (id.length == 0 && name.length != 0) {
          $j(this).attr('id', name);
        }
      });
    
      $j('#main label').inFieldLabels();
    
      $j('.rule span').click(function() {
    	  $j.scrollTo(0, 1000, {axis:'y'});
    	  return false;
     });
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    .attr(‘id’) doesn’t work if there is no ID attribute. Try using the DOM references this.id.length and this.name.length directly in the conditional like so:
    if (this.id.length == 0 && this.name.length != 0) {
    and get rid of the assignments to var id and var name.

    Note that $j(this).id.length does not work because .id is not a jQuery property, it is a DOM property.

    Thread Starter redhorizon0289

    (@redhorizon0289)

    bcworkz,
    Thanks for your input, worked like a charm, the menu rollovers are working again and widgets are pulling content correctly.

    Thanks again, cheers.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘JS error UndefinedID in function preventing content loading’ is closed to new replies.