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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:27:58+00:00 2026-05-14T04:27:58+00:00

I have a list of states, each with some data associated with it, displayed

  • 0

I have a list of states, each with some data associated with it, displayed in a table, with a checkbox next to each state. I have it successfully computing the sum of input values of all checked states, but I need to store the additional data for each state in a 3D array so that I can display it later in the form’s summary, showing the user just the states they selected. I have found a few solutions, but haven’t been able to get any to work for my setup. This is what I have so far (hoping I’m not leaving any important code out):

var returnDb = new Array();
var inc = 0;
var returnState = '';
var returnNum = '';
var returnEmail = '';
$("input:checked").each(function() {
    var value = 1*$(this).attr("title");
    var value_vendors = 1*$(this).attr("title");

    // These are causing my script to stop
    returnState = ''. $(this).closest('tr').find('td:eq(1)').text();
    returnNum = ''. $(this).closest('tr').find('td:eq(2)').text();
    returnEmail = ''. $(this).closest('tr').find('td:eq(3)').text();

    returnDb[inc] = [['' . returnState, '' . returnNum, '' . returnEmail]];

    total += parseInt(value);
    vendors += parseInt(value_vendors);

    inc++;
});

When I comment out the three lines that cause my script to stop, everything works fine. Any idea what I’m doing wrong or if there is a better approach to this?

  • 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-14T04:27:59+00:00Added an answer on May 14, 2026 at 4:27 am

    In javascript you concatenate strings using +, but you don’t even need that here. I would also use parseInt to extract the values. Total and vendors also need to be initialized. Finally, each will give you the index as a argument so there’s no need for your counter.

    Edit: Note I changed the assignment to the returnDb array. Your original assigns an array containing an array of values to each array element in returnDb. The new code assigns an object with three properties (state, num, email) to each element in returnDb. Your original may have been correct — I don’t know how you are using it — but I think the object approach is more usable in most instances.

    var returnDb = new Array();         
    var returnState = '';     
    var returnNum = '';     
    var returnEmail = ''; 
    var total = 0;
    var vendors = 0;    
    $("input:checked").each(function(i) {     
        var value = parseInt( $(this).attr("title") );     
        var value_vendors = parseInt( $(this).attr("title") );     
    
        // These are causing my script to stop     
        returnState = $(this).closest('tr').find('td:eq(1)').text();     
        returnNum = $(this).closest('tr').find('td:eq(2)').text();     
        returnEmail = $(this).closest('tr').find('td:eq(3)').text();     
    
        //returnDb[i] = [[returnState, returnNum, returnEmail]];   
        returnDb[i] = { state: returnState, num: returnNum, email: returnEmail };  
    
        total += value;     
        vendors += value_vendors;        
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of lists that looks like this: x[[state]][[year]] . Each element
In SQL Server, I have a table where a column A stores some data.
I have a table that contains some user data: user_id | guest_id | time_seen
I have two views of some data: a list view (a ListBox now, but
Basically, I have a list of dates in a SQL table with some statistics
I have a largish table of data pulled from my database (~1500 rows, each
I have a List<State> of State entity objects, and each State object has collections
I need a city/state/country Dynamic Drop-Down List in my Wordpress registration page. I have
I have list of articles on the page in table and i want to
I have list of structure. I want to modify a particular data from the

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.