D
Daz
Hi everyone.
First of all, I would be interested to know if anyone knows of a decent
plugin for IE that validates JavaScript. I am running IE 5, 5.5 and 6
through wine (Windows Emulator) on Linux, so I haven't yet found one.
However, this is my problem:
I have the following piece of script:
// This is just test data...
var books = Array(
{ret:{o:20,u:50},reg:{o:12,u:34},n:"A"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"B"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"C"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"D"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"E"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"F"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"G"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"H"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"I"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"J"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"K"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"L"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"M"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"N"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"O"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"P"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"Q"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"R"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"S"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"T"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"U"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"V"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"W"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"X"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"Y"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"Z"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"0-9"}
);
function appendTotals()
{
var totalRetiredOwned;
var totalRetiredUnowned;
var totalRegularOwned;
var totalRegularUnowned;
for (var i = 0; i < books.length; i++)
{
totalRetiredOwned += books.ret.o;
totalRetiredUnowned += books.ret.u;
totalRegularOwned += books.reg.o;
totalRegularUnowned += books.reg.u;
}
var totals =
{ret:{o:totalRetiredOwned,u:totalRetiredUnowned},
reg:{o:totalRegularOwned,u:totalRegularUnowned},n:"Totals"};
books.push(totals);
}
appendTotals();
IE seems to have a problem with the line that reads
'books.push(totals);' When I comment it out, the rest of the script
runs. When I leave it in, IE throws a wobbler, I get an error and the
script stops. It's all well and good that IE reports that there's an
error, but if only it told me what the fricking error was! I feel that
Microsoft is laughing at me, along with the other users who have to
seriously modify/hack/botch their otherwise, well written scripts in
order to compensate for where IE has gone awry. Even when I change
'books.push(totals);' to 'books.push("blah");', it still gets it's
knickers in a twist. Perhaps JavaScript doesn't allow different data
types in an array? I'm not 100% certain to be honest.
Would anyone please be so kind as to point out where I might be going
wrong? The entire script worls beautifully in Firefox, as always, it's
IE that is 'the thorn in my side', (only replace 'thorn' with '12 inch
spike').
Many thanks in advance.
Seriously confused.
Daz.
First of all, I would be interested to know if anyone knows of a decent
plugin for IE that validates JavaScript. I am running IE 5, 5.5 and 6
through wine (Windows Emulator) on Linux, so I haven't yet found one.
However, this is my problem:
I have the following piece of script:
// This is just test data...
var books = Array(
{ret:{o:20,u:50},reg:{o:12,u:34},n:"A"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"B"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"C"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"D"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"E"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"F"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"G"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"H"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"I"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"J"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"K"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"L"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"M"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"N"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"O"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"P"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"Q"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"R"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"S"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"T"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"U"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"V"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"W"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"X"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"Y"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"Z"},
{ret:{o:20,u:50},reg:{o:12,u:34},n:"0-9"}
);
function appendTotals()
{
var totalRetiredOwned;
var totalRetiredUnowned;
var totalRegularOwned;
var totalRegularUnowned;
for (var i = 0; i < books.length; i++)
{
totalRetiredOwned += books.ret.o;
totalRetiredUnowned += books.ret.u;
totalRegularOwned += books.reg.o;
totalRegularUnowned += books.reg.u;
}
var totals =
{ret:{o:totalRetiredOwned,u:totalRetiredUnowned},
reg:{o:totalRegularOwned,u:totalRegularUnowned},n:"Totals"};
books.push(totals);
}
appendTotals();
IE seems to have a problem with the line that reads
'books.push(totals);' When I comment it out, the rest of the script
runs. When I leave it in, IE throws a wobbler, I get an error and the
script stops. It's all well and good that IE reports that there's an
error, but if only it told me what the fricking error was! I feel that
Microsoft is laughing at me, along with the other users who have to
seriously modify/hack/botch their otherwise, well written scripts in
order to compensate for where IE has gone awry. Even when I change
'books.push(totals);' to 'books.push("blah");', it still gets it's
knickers in a twist. Perhaps JavaScript doesn't allow different data
types in an array? I'm not 100% certain to be honest.
Would anyone please be so kind as to point out where I might be going
wrong? The entire script worls beautifully in Firefox, as always, it's
IE that is 'the thorn in my side', (only replace 'thorn' with '12 inch
spike').
Many thanks in advance.
Seriously confused.
Daz.