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 8585429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T22:03:45+00:00 2026-06-11T22:03:45+00:00

I want to create a code that get’s the values from array [1, 2,

  • 0

I want to create a code that get’s the values from array ["1", "2", "3"] and then it creates a new row with 7 of this. The array will have near 90 values, so from 1-7 is in the first row, 8-14 in another and so. I created this code but it just freezes the website and crashes the browser, so I would like you to tell me where’s the mistake.

var newVals = new Array("1", "2", "3"..."81");
var target = ".content table";
var activeTar = target + " .active";
for(var i = 0; i < newVals.length; i++){
    for (var y = 0; y < 7; y++){
        if(y == 0){
            jQuery(target).append('<tr class="active"></tr>');
        }
        var valId = newVals[i];
        var valImg = "http://sub.domain.com/" + valId + "/picture";
        var valCode = '<td class="cell"><a class="toggleAdd" tabindex="0" data-icon="'+valId+'"><img src="'+valImg+'"></a></td>';
        jQuery(activeTar).append(valCode);
        if(y == 6){
            jQuery(activeTar).removeClass("active");
            y = -1;
        }
    }
}
jQuery(".toggleAdd").live("click", function(){
    jQuery("input", jQuery(this).closest('form')).val(jQuery("input", jQuery(this).closest('form')).val() + jQuery(this).attr("data-icon"));
});
  • 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-06-11T22:03:46+00:00Added an answer on June 11, 2026 at 10:03 pm

    Seems like you have the "active" class just for doing DOM selecto to insert into the proper row.

    No need. Just save the row in a variable, append to it, and make and save a new row every seven items.

    var newVals = new Array("1", "2", "3", /*...,*/ "81"),
        target = jQuery(".content table"),
        activeRow;
    
    $.each(newVals, function(i, valId) {
        if(i % 7 === 0)
            activeRow = jQuery('<tr></tr>').appendTo(target);
    
        activeRow.append('<td class="cell"><a class="toggleAdd" tabindex="0" data-icon="'+valId+'"><img src="http://sub.domain.com/' + valId + '/picture"></a></td>');
    });
    

    This uses the modulus operator to determine if it is time to make a new row.

    with respect to the handler, you can clean it up a bit if you use variables. Also, if you’re using jQuery 1.7 or later, you should use on instead of live.

    jQuery(document).on("click", ".toggleAdd", function(){
        var input = jQuery(this).closest('form').find("input"),
            v = input.val() + jQuery(this).attr("data-icon");
    
        input.val(v);
    });
    

    You should replace document with a selector that represents the deepest container that holds all the .toggleAdd elements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create a helper method that could be called from different code-behind
I have a DataTable that I get from the DB, I want to create
I want to create log file. this is the code that i try to
I want to create a simple application in Assembly (with NASM) that will get
I want to create a global object that represents the current user in Code
I want to create tabs which will show certain views I create through code.
i want create Dynamic Slideshow in Jquery i'm Write this code var ctx =
I want to create an item to sitecore using code behind. I found this
I want to create a capped collection from Java code. I found the syntax
I want to create a new Rally user with the following C# code DynamicJsonObject

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.