Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 249327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:25:05+00:00 2026-05-11T21:25:05+00:00

I have a custom jQuery script that works fine in all bowsers but one

  • 0

I have a custom jQuery script that works fine in all bowsers but one (Explorer 6, 7, 8?).

The purpose of the code is to allow a user to add multiple form fields to their form (if the user want more than one phone number or more than one web address).

It is written so that any “A” tag with a class containing “add” is bound to the jQuery function.

The error I am getting is as follows:

///////////////////////////////
Line: 240
Char: 5
Error: 'this.id.3' is null or not an object
Code: 0
///////////////////////////////

HTML of form:
(please note that I am aware that the form tags are not here, this is a small portion of a larger form.

<ul>
<li>
    <ul>
    <li class="website">
        <input id="website1_input" name="website[1][input]" type="text" value="www.test.org"/>
        <input type="checkbox" id="website1_delete" name="website[1][delete]" class="element radio" value="1" />
        <label for="website1_delete">Delete</label>     
    </li>
    </ul>
    <a href="#" id="addWebsite">add another website</a>
    </li>
</ul>

And now the jQuery:

There should be on a page a ul containing at least one li.
All the lis should have a certain class like “phone” or “address”
After the /ul There should be a link with a matching id, like
“addPhone” or “addAddress”. The href attribute should be “#”.

function makeAddable(theClass) {
  $('#add' + theClass[0].toUpperCase() + theClass.substr(1)).click(function() {
    var numItems = $('.' + theClass).length;
    var newItem = $('.' + theClass).eq(numItems - 1).clone();
    newItem.find('input[type=text]').val('');
    numItems++; // number in the new IDs

    // keep ids unique, linked to label[for], and update names
    // id & for look like: phone1_type, phone1_ext, phone13_p1, etc.
    // names look like: phone[1][type], phone[1][ext], phone[13][p1], etc.
    newItem.find('[id^=' + theClass + ']').each(function(i) {
      var underscoreIndex = this.id.indexOf('_');
      var idNum = this.id.substring(theClass.length, underscoreIndex);
      this.id = this.id.replace(idNum, numItems);
    });
    newItem.find('[for^=' + theClass + ']').each(function(i) {
        var jqthis = $(this);
        var forAttr = jqthis.attr('for');
        var underscoreIndex = forAttr.indexOf('_');
        var idNum = forAttr.substring(theClass.length, underscoreIndex);
        forAttr = forAttr.replace(idNum, numItems);
        jqthis.attr('for', forAttr);
    });
    newItem.find('[name^=' + theClass + ']').each(function(i) {
        var jqthis = $(this);
        var nameAttr = jqthis.attr('name');
        var bracketIndex = nameAttr.indexOf(']');
        var idNum = nameAttr.substring(theClass.length + 1, bracketIndex);
        nameAttr = nameAttr.replace(idNum, numItems);
        jqthis.attr('name', nameAttr);
    });

    $(this).prev('ul').append(newItem);
    return false;
  });
}

// Automatically enable all <a href="#" id="addSomething"> links
$(function() {
  $('a[href=#][id^=add]').each(function(i) {
    makeAddable( this.id[3].toLowerCase() + this.id.substr(4) );
  });
});
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T21:25:05+00:00Added an answer on May 11, 2026 at 9:25 pm
    this.id.charAt(3).toLowerCase()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a code for jqGrid with custom editFunc that opens my own jQuery-UI
How do i select elements that have my custom data attribute data-validate with jQuery
I'm trying to use $(button).button(); but jquery-ui-1.8.16.custom.min.js used by SlickGrid doesn't have the button
I have a problem with an image that I am applying a custom jquery
I have button and that jQuery script (to start the progress bar): <script src=../_Files/JScripts/jquery-1.3.2.js
I have a form with jquery validation. I have some custom rules, but they
I have a site with a form with autocomplete using jquery. It works fine,
Ok I have a page that uses 3 plugins and custom code. Fullscreenr ScrollTo
I have a fairly complex project in the works that requires a custom volume
I have a custom jQuery plugin which binds a change event to a form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.