[Javascript] I have hit a brick wall
Terry Riegel
riegel at clearimageonline.com
Thu Sep 7 10:33:44 CDT 2006
Thanks Jonathan,
That works for the array, but I need to swap out the objects
represented by the ID. I need soemthing similar to the swapNodes()
function you wrote yesterday.
This is my humble (non-working) attempt so far.
function rippleNodes(a,k)
{
var placeHolder = document.createElement(k);
var i=document.getElementById(a[0])
for (x=0; x<a.length; x++)
{
if (x==0)
{
i.parentNode.replaceChild(placeHolder,i)
}
else
{
var n=document.getElementById(a[x])
var n1=document.getElementById(a[x-1])
n.parentNode.replaceChild(n1,n)
}
}
placeHolder.parentNode.replaceChild(i, placeHolder);
}
Terry
On Sep 7, 2006, at 11:17 AM, Jonathan Buchanan wrote:
> On 9/7/06, Terry Riegel <riegel at clearimageonline.com> wrote:
>> Hello,
>>
>> For some reason I can't seem to get my head around this problem. I
>> was able to get a swapImages() function working yesterday to
>> basically swap 2 images out. I think my work on that is clouding my
>> thinking for the problem before me. Can someone help me with my
>> logic.
>>
>> I have an array of Objects (actually their ID's) like
>>
>>
>> i[0] = 'imageA'
>> i[1] = 'imageB'
>> i[2] = 'imageC'
>> i[3] = 'imageD'
>> i[4] = 'imageE'
>> i[5] = 'imageF'
>>
>> and I would like move imageA to the last position, and ripple all the
>> others up. So the result would be...
>>
>> i[0] = 'imageB'
>> i[1] = 'imageC'
>> i[2] = 'imageD'
>> i[3] = 'imageE'
>> i[4] = 'imageF'
>> i[5] = 'imageA'
>>
>> For some reason this seems like a simple problem, but I can't seem to
>> come up with the logic for executing it. Any Ideas?
>>
>> Terry
>
> i.push(i.shift());
>
> Regards,
> Jonathan.
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list