Title: JS error UndefinedID in function preventing content loading
Last modified: August 21, 2016

---

# JS error UndefinedID in function preventing content loading

 *  [redhorizon0289](https://wordpress.org/support/users/redhorizon0289/)
 * (@redhorizon0289)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/js-error-undefinedid-in-function-preventing-content-loading/)
 * 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](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](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/js-error-undefinedid-in-function-preventing-content-loading/#post-4336505)
 * .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](https://wordpress.org/support/users/redhorizon0289/)
 * (@redhorizon0289)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/js-error-undefinedid-in-function-preventing-content-loading/#post-4336507)
 * 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.

## Tags

 * [Coding](https://wordpress.org/support/topic-tag/coding/)
 * [contact-form](https://wordpress.org/support/topic-tag/contact-form/)
 * [javascript](https://wordpress.org/support/topic-tag/javascript/)
 * [js](https://wordpress.org/support/topic-tag/js/)
 * [rollovers](https://wordpress.org/support/topic-tag/rollovers/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [redhorizon0289](https://wordpress.org/support/users/redhorizon0289/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/js-error-undefinedid-in-function-preventing-content-loading/#post-4336507)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
