T
Tuxedo
I have an array in a particular order in a frame (mainframe) which I'd like
to reorder from an onload call of another frame, while from that frame, the
only thing I'd like to specify is which one named array item should be the
first.
In other words, if this is the original array:
var myArray = new Array('a1,'a2','a3','a4','a5')
I'd like to reorder it via a function by only specifying which one item I'd
like to have first. The function, in the same frame as the array, could be
named something lfor example:
function reorder_the_array(i){
swapping or reorder code goes here
}
So if from the other frame I call reorder_the_array() and pass the one item
I'd like to have first, for example, 'a3':
<body onload="top.mainframe.reorder_the_array('a3')";
What's a good way to change the array or make a copy of it and create a new
one without specifying all the array items from where the function is
called?
As mentioned, all I would like to specify in the call from the second frame
is which one item I would like to have first. So for example, by running
reorder_the_array('a3'), the reordered or new array would then become:
a3,a2,a1,a4,a5
If as above, that would simply be swapping positions of a1 and a3.
However, I may sometimes pass 'a1' as the item to be the first in which
case there doesn't need to be any chance. But this can easily be done by
preventing the swapping code from running by a simple if condition.
In fact, it doesn't make any difference which exact order the items are
juggled in the remaining part of the array, as long as:
1) The item passed through the function is placed first
2) The remaining array entries are all unique, so all original array items
exist and that it is the same length as the original.
I guess this is a pretty simple task, and there are probably many ways to
do it. However, I'm note very well-versed on this subject so any pointers
would be mostly appreciated.
Many thanks!
to reorder from an onload call of another frame, while from that frame, the
only thing I'd like to specify is which one named array item should be the
first.
In other words, if this is the original array:
var myArray = new Array('a1,'a2','a3','a4','a5')
I'd like to reorder it via a function by only specifying which one item I'd
like to have first. The function, in the same frame as the array, could be
named something lfor example:
function reorder_the_array(i){
swapping or reorder code goes here
}
So if from the other frame I call reorder_the_array() and pass the one item
I'd like to have first, for example, 'a3':
<body onload="top.mainframe.reorder_the_array('a3')";
What's a good way to change the array or make a copy of it and create a new
one without specifying all the array items from where the function is
called?
As mentioned, all I would like to specify in the call from the second frame
is which one item I would like to have first. So for example, by running
reorder_the_array('a3'), the reordered or new array would then become:
a3,a2,a1,a4,a5
If as above, that would simply be swapping positions of a1 and a3.
However, I may sometimes pass 'a1' as the item to be the first in which
case there doesn't need to be any chance. But this can easily be done by
preventing the swapping code from running by a simple if condition.
In fact, it doesn't make any difference which exact order the items are
juggled in the remaining part of the array, as long as:
1) The item passed through the function is placed first
2) The remaining array entries are all unique, so all original array items
exist and that it is the same length as the original.
I guess this is a pretty simple task, and there are probably many ways to
do it. However, I'm note very well-versed on this subject so any pointers
would be mostly appreciated.
Many thanks!