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

  • SEARCH
  • Home
  • 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 6474873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:38:19+00:00 2026-05-25T06:38:19+00:00

jquery 1.6.2 / Firefox 6.0.1 OK I’m working on this shipment manager interface and

  • 0

jquery 1.6.2 / Firefox 6.0.1

OK I’m working on this shipment manager interface and when the page is loaded, each table row tr is assigned an id “shipment_XXXXX” where XXXXX is the id of the shipment from the database.

All the data regarding the shipment is, in PHP set to a multidimensional associative array which contains “shipmentItems” and “pkgs” among other things which are irrelevant. The shipmentItems object is a regular numeric array, where each element has several associative values such as “name”, “qty”, “price” so for example:

$shipmentItems[0]["name"] = "item 1";
$shipmentItems[0]["qty"] = 5;
$shipmentItems[0]["price"] = 20.00;

$shipmentItems[1]["name"] = "item 2";
$shipmentItems[1]["qty"] = 3;
$shipmentItems[1]["price"] = 5.00;

This array indicates all of the items that are part of this shipment in whole.

The other array pkgs is a list of each package in the shipment and each package has a packing_slip object/associative array. Example:

PACKAGE #1
$pkgs[0]['packing_slip'][0]['name'] = "item 1";
$pkgs[0]['packing_slip'][0]['qty'] = 3;
$pkgs[0]['packing_slip'][0]['price'] = 20.00;
$pkgs[0]['packing_slip'][1]['name'] = "item 2";
$pkgs[0]['packing_slip'][1]['qty'] = 1;
$pkgs[0]['packing_slip'][1]['price'] = 50.00;

PACKAGE #2
$pkgs[1]['packing_slip'][0]['name'] = "item 1";
$pkgs[1]['packing_slip'][0]['qty'] = 2;
$pkgs[1]['packing_slip'][0]['price'] = 20.00;
$pkgs[1]['packing_slip'][1]['name'] = "item 2";
$pkgs[1]['packing_slip'][1]['qty'] = 2;
$pkgs[1]['packing_slip'][1]['price'] = 50.00;

You’ll see that the pkg array has the full shipment item list for each packing slip for each package. if you add the 0index qty from both packages you’ll see that it adds up to the full shipment qty for that item line.

This set of data gets converted to a JSON string by php and tucked into a hidden form element within its corrosponding row.

After the page is loaded, jquery goes through each hidden json element, parses the json string to an object, the attaches the object to the TR.data(‘shipmentItems’) and TR.data(‘pkgs’) for each shipment in the list.

This is where things get funky…

I’m doing a function where the user can add a new package to the shipment. When they do this they are prompted to specify which package has how many quantities of each item in the whole shipment. They essentially lay out the packing slips.

The function they execute after they have mapped out the quantities, recreates the pkgs array(object) on the fly, which it gets from its rows .data(‘pkgs’) container – and then re-attaches the pkgs object back to the data(‘pkgs’) container.

I have logged the output of this function heavily and the quantities are all being assigned to the proper values see here:

var shipmentItems = $('#shipment_'+shipid).data('shipmentItems');
var pkgs = $('#shipment_'+shipid).data('pkgs');
var pkgnum = pkgs.length; // always returns one higher than last index.

// add new pkg to array
pkgs[pkgnum] = new Object();
pkgs[pkgnum].weight = weight;

console.log("("+pkgnum+") pkgs length: " + pkgs.length);

// overwrite packing slip data.
for(var x = 0; x < pkgs.length; x++) {
    var curPS = new Array();
    var curins = 0;
    for(var y = 0; y < shipmentItems.length; y++) {
        var curqty = parseInt($('#pkgqty-'+y+'-'+x).val());
        curins += curqty * shipmentItems[y]['price'];
        curPS.push(shipmentItems[y]);
        console.log("["+y+"] before: " + curPS[y]['qty']);
        curPS[y]['qty'] = curqty;
        console.log("["+y+"] after: " + curPS[y]['qty']);
    }
    console.log(curPS[0]['qty'] + ' - ' + curPS[1]['qty']);
    pkgs[x].packing_slip = curPS;
    pkgs[x].insurance = curins;
}

// write pkgs data()
$('#shipment_'+shipid).removeData('pkgs');
$('#shipment_'+shipid).data('pkgs', pkgs);

The log output of the above is as follows:

(1) pkgs length: 2
[0] before: 3
[0] after: 2
[1] before: 4
[1] after: 3
2 - 3 // value of curPS[0]['qty'] and curPS[1]['qty'] for pkg#1 - pkgs[0] is set to curPS at this point.
[0] before: 2
[0] after: 1
[1] before: 3
[1] after: 1
1 - 1 // value of curPS[0]['qty'] and curPS[1]['qty'] for pkg#2 - pkgs[1] is set to curPS at this point.

This looks like it worked, right? Wrong. After the function completes I have a button I can push that prints out all the data() vars for a row. Not only are the qty value of every single pkg[‘packing_slip’][x] item set to 1, but if I look at the shipmentItems from this same object log, the qty values for all of the shipmentItems have also been reset to 1. Which is odd because at no point in the code does shipmentItems ever get overwritten and should still be the exact same as it was when the page loaded…

Anyone have any ideas whats going on here?

  • 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-25T06:38:19+00:00Added an answer on May 25, 2026 at 6:38 am

    maybe it’s because you pass shipmentItems by Reference – curPS.push(shipmentItems[y]);
    Try to pass it by Value – curPS.push(shipmentItems[y].slice());

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

Sidebar

Related Questions

Why is that jquery dialog does not work in firefox? this is working in
Im new to jquery and I am stuck. This page works perfectly in Firefox
I am currently testing this in Mozilla FireFox 3.0.5 using FireBug 1.3.0 with jQuery
I've got the new autocomplete widget in jQuery UI 1.8rc3 working great in Firefox.
This jQuery statement works in recent versions of Firefox and Chrome but throws an
In FireFox I have this jQuery at the end of the body: $(document).ready(function() {
jquery's select() is not working in IE, but its working fine in Firefox and
I have a jquery slider which is working good in Firefox and Chrome. But
this jQuery script works on firefox, it give alert. but it doesn't work in
My little jQuery snippet works great in Firefox; but fails in IE. This is

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.