[thelist] Javascript array weirdness

Chrome admin at chrome.me.uk
Fri Aug 21 12:53:25 CDT 2009

Hi all

I've got a weird problem that I genuinely can't figure out (either that or
it's a Friday thing)... I have this function:

objXHR.prototype.getPrice = function () {
    this.url = theURL;
    var n=theForm.elements.length;

    for (var i=0; i<n; i++) {
        var el = theForm.elements[i];
        switch (el.type) {
            case 'select':
            case 'select-one':
            case 'text':
            case 'hidden':
                this.request[el.name] = escape(el.value);
            case 'checkbox':
            case 'radio':
                if (true == el.checked)    this.request[el.name] =

    this.getData('post', 'handlePrice()');

As you can see this is meant to populate the array this.request with values
from the theForm... Problem is that the array seems to be empty... The
strange thing is if that you call the array value by its key it has the
value but if you try to iterate through it it's blank (or seems to be)

I tried inserting a hard value of this.request[1] = 'Test'; and got the
output as [undefined, 'Test']... so I tried this.request['test'] = 'Test';
and got [ ]

So I tried replacing the this.request array as a locally defined array
called request... Still blank

Anyone know what's going on?  I'm about to have a sub-orbital PC at this
rate ;)

If anyone wants a link to the failing site and a rundown of what the whole
script is supposed to do please mail me personally (it's a client's site
that isn't ready to go live yet... obvious really considering my bit doesn't
work :) )



More information about the thelist mailing list