From loic_sephiroth at yahoo.es Fri Sep 1 03:37:17 2006
From: loic_sephiroth at yahoo.es (=?ISO-8859-1?Q?Lo=EFc?=)
Date: Fri, 01 Sep 2006 10:37:17 +0200
Subject: [Javascript] Knowing wich function called another function
within the code of the latter.
Message-ID: <44F7F13D.20402@yahoo.es>
[quote="Matt Warden"]
The only thing I know of is arguments.caller, which was deprecated in
JS1.3.
[/quote]
Thank you for your answer, Matt. I've searched the topic, but it is
indeed a deprecated method, and therefore i can't use it. I also
realized that the arguments.caller would return the body element, since
the include functions are called as a global method (recall the Main.js
file) to a Class file, so it wouldn't have served me as i expected.
Well, i'll try a different approach to solve the problem. The only way i
can think of now, is to pass the qualified name of the Class to the
include method, but i find it an ugly thing to write and read.
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y m?viles desde 1 c?ntimo por minuto.
http://es.voice.yahoo.com
From lists at dwsasia.com Sun Sep 3 21:13:05 2006
From: lists at dwsasia.com (Peter Lauri)
Date: Mon, 4 Sep 2006 09:13:05 +0700
Subject: [Javascript] Odd behaviour?
Message-ID: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
Hi,
I make an AJAX request and on the server side this is generated (I push it
into a database to detect problem before outputting it in the script that is
requested with get):
where it breaks comes from a database field. If
the field is empty this happens, if it is not empty everything works fine.
I am using innerHTML property to insert this into the web page.
When I make this request on a "static" way it works fine all cases, but with
AJAX it does not work. This makes me confused :)
/Peter
From david at dorward.me.uk Mon Sep 4 04:06:46 2006
From: david at dorward.me.uk (David Dorward)
Date: Mon, 4 Sep 2006 10:06:46 +0100
Subject: [Javascript] Odd behaviour?
In-Reply-To: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
Message-ID: <20060904090646.GA26749@us-lot.org>
On Mon, Sep 04, 2006 at 09:13:05AM +0700, Peter Lauri wrote:
> I make an AJAX request and on the server side this is generated (I push it
> into a database to detect problem before outputting it in the script that is
> requested with get):
>
>
>
Invalid.
elements may not be children of
elements, and
this is an area where browsers act differently in their attempts to
compensate for the error.
> Close
http://www.jibbering.com/faq/#FAQ4_24 and you have a rogue quote there
too.
--
David Dorward http://dorward.me.uk
From riegel at clearimageonline.com Wed Sep 6 07:56:00 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Wed, 6 Sep 2006 08:56:00 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <20060904090646.GA26749@us-lot.org>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
Message-ID: <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Hello,
I would like to swap out an image in an application I am writing.
Basically I want to swap two image tags, the trick is I want to swap
their ID and NAME tags also.
For example, I have the following HTML...
...
...
...
that I would like to use javacscript to make into...
...
...
...
The important thing Is I would like to swap all of the attributes
out. i.e. width,height,id,name,src
Thanks,
Terry Riegel
From mdougherty at pbp.com Wed Sep 6 08:11:00 2006
From: mdougherty at pbp.com (Mike Dougherty)
Date: Wed, 06 Sep 2006 09:11:00 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID:
wouldn't it be easier just to swap their src attributes?
On Wed, 6 Sep 2006 08:56:00 -0400
Terry Riegel wrote:
> Hello,
>
> I would like to swap out an image in an application I am writing. Basically I want to swap two
>image tags, the trick is I want to swap their ID and NAME tags also.
> The important thing Is I would like to swap all of the attributes out. i.e.
>width,height,id,name,src
From riegel at clearimageonline.com Wed Sep 6 08:34:45 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Wed, 6 Sep 2006 09:34:45 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID: <5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
Sure, but then I would have an ID that represented the wrong image.
And any subsequent manipulations with that image would be for the
wrong ID.
Swapping the src tag makes it look like it has swapped, but further
javascript queries are going to be referencing the wrong ID, height,
width, etc...
Terry
On Sep 6, 2006, at 9:11 AM, Mike Dougherty wrote:
> wouldn't it be easier just to swap their src attributes?
>
> On Wed, 6 Sep 2006 08:56:00 -0400
> Terry Riegel wrote:
>> Hello,
>> I would like to swap out an image in an application I am writing.
>> Basically I want to swap two image tags, the trick is I want to
>> swap their ID and NAME tags also.
>> The important thing Is I would like to swap all of the attributes
>> out. i.e. width,height,id,name,src
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
From matt.ludbrook at emicassociates.co.uk Wed Sep 6 08:46:34 2006
From: matt.ludbrook at emicassociates.co.uk (Matt Ludbrook)
Date: Wed, 6 Sep 2006 14:46:34 +0100
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
Message-ID: <002f01c6d1ba$df6f3f90$0100a8c0@emicmatt>
But you said you wanted to swap the IDs. Your initial description makes it
sound like you want to swap everything except the src. In that case swapping
the src would be the easier way of solving your prob.
Matt
-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Terry Riegel
Sent: 06 September 2006 14:35
To: [JavaScript List]
Subject: Re: [Javascript] Changing an Objects ID and Name
Sure, but then I would have an ID that represented the wrong image.
And any subsequent manipulations with that image would be for the wrong ID.
Swapping the src tag makes it look like it has swapped, but further
javascript queries are going to be referencing the wrong ID, height, width,
etc...
Terry
On Sep 6, 2006, at 9:11 AM, Mike Dougherty wrote:
> wouldn't it be easier just to swap their src attributes?
>
> On Wed, 6 Sep 2006 08:56:00 -0400
> Terry Riegel wrote:
>> Hello,
>> I would like to swap out an image in an application I am writing.
>> Basically I want to swap two image tags, the trick is I want to swap
>> their ID and NAME tags also.
>> The important thing Is I would like to swap all of the attributes
>> out. i.e. width,height,id,name,src
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/438 - Release Date: 05/09/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.11.7/438 - Release Date: 05/09/2006
From rer at datacompusa.com Wed Sep 6 08:52:50 2006
From: rer at datacompusa.com (Roger Roelofs)
Date: Wed, 6 Sep 2006 09:52:50 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
Message-ID: <0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
Terry,
Without seeing the page, I can't tell if it would work for sure, but,
couldn't you just set the className and use css to get the display
you want?
On Sep 6, 2006, at 9:34 AM, Terry Riegel wrote:
> Sure, but then I would have an ID that represented the wrong image.
> And any subsequent manipulations with that image would be for the
> wrong ID.
>
> Swapping the src tag makes it look like it has swapped, but further
> javascript queries are going to be referencing the wrong ID,
> height, width, etc...
>
> Terry
>
>
> On Sep 6, 2006, at 9:11 AM, Mike Dougherty wrote:
>
>> wouldn't it be easier just to swap their src attributes?
>>
>> On Wed, 6 Sep 2006 08:56:00 -0400
>> Terry Riegel wrote:
>>> Hello,
>>> I would like to swap out an image in an application I am
>>> writing. Basically I want to swap two image tags, the trick is I
>>> want to swap their ID and NAME tags also.
>>> The important thing Is I would like to swap all of the
>>> attributes out. i.e. width,height,id,name,src
Roger
--
Roger Roelofs web www.datacompusa.com
Datacomp Appraisal Services Email rer at datacompusa.com
3215 Eaglecrest Drive, NE
Grand Rapids, MI 49525-4593
From flavio at economisa.com.br Wed Sep 6 08:56:15 2006
From: flavio at economisa.com.br (=?ISO-8859-1?Q?Fl=E1vio_Gomes?=)
Date: Wed, 06 Sep 2006 10:56:15 -0300
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu> <20060904090646.GA26749@us-lot.org> <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
Message-ID: <44FED37F.5080603@economisa.com.br>
Havent tought a lot, but you could store all images informations in a
array, then you make a simple function to swap them, taking care not to
let two images with the same ID.
Terry Riegel escreveu:
> Sure, but then I would have an ID that represented the wrong image.
> And any subsequent manipulations with that image would be for the
> wrong ID.
>
> Swapping the src tag makes it look like it has swapped, but further
> javascript queries are going to be referencing the wrong ID, height,
> width, etc...
>
> Terry
>
>
> On Sep 6, 2006, at 9:11 AM, Mike Dougherty wrote:
>
>> wouldn't it be easier just to swap their src attributes?
>>
>> On Wed, 6 Sep 2006 08:56:00 -0400
>> Terry Riegel wrote:
>>
>>> Hello,
>>> I would like to swap out an image in an application I am writing.
>>> Basically I want to swap two image tags, the trick is I want to
>>> swap their ID and NAME tags also.
>>> The important thing Is I would like to swap all of the attributes
>>> out. i.e. width,height,id,name,src
>>
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
--
Flavio Gomes
flavio at economisa.com.br
From jonathan.buchanan at gmail.com Wed Sep 6 09:20:27 2006
From: jonathan.buchanan at gmail.com (Jonathan Buchanan)
Date: Wed, 6 Sep 2006 15:20:27 +0100
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID:
On 9/6/06, Terry Riegel wrote:
> Hello,
>
> I would like to swap out an image in an application I am writing.
> Basically I want to swap two image tags, the trick is I want to swap
> their ID and NAME tags also.
>
> For example, I have the following HTML...
>
>
> ...
>
> ...
>
> ...
>
>
> that I would like to use javacscript to make into...
>
> ...
>
> ...
>
> ...
>
> The important thing Is I would like to swap all of the attributes
> out. i.e. width,height,id,name,src
>
> Thanks,
>
> Terry Riegel
If you want to swap element locations (which is what you're really
doing, if I've understood the question correctly), do it directly
using the DOM instead of fiddling about with element attributes:
function swapNodes(n1, n2)
{
var placeHolder = document.createElement("span");
n1.parentNode.replaceChild(placeHolder, n1);
n2.parentNode.replaceChild(n1, n2);
placeHolder.parentNode.replaceChild(n2, placeHolder);
}
swapNodes(document.getElementById("abc"), document.getElementById("def"));
Regards,
Jonathan.
From tedd at sperling.com Wed Sep 6 09:32:20 2006
From: tedd at sperling.com (tedd)
Date: Wed, 6 Sep 2006 10:32:20 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID:
At 8:56 AM -0400 9/6/06, Terry Riegel wrote:
>I would like to swap out an image in an application I am writing.
>Basically I want to swap two image tags, the trick is I want to swap
>their ID and NAME tags also.
>
>For example, I have the following HTML...
> ...
>
>
> ...
>that I would like to use javacscript to make into...
> ...
>
>
> ...
>
>The important thing Is I would like to swap all of the attributes
>out. i.e. width,height,id,name,src
Terry:
I don't know about objects, but you can do what you described above
several ways:
1. With ajax you can change the html between divs.
2. With css you can absolutely position both and then swap with a
style switcher.
3. With css you can use the visibility attribute showing both
combinations and then change visibility/hidden with a style switcher.
4. Or, you can do it like this via js:
http://xn--ovg.com/a1.php
hth's
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From riegel at clearimageonline.com Wed Sep 6 09:41:28 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Wed, 6 Sep 2006 10:41:28 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <002f01c6d1ba$df6f3f90$0100a8c0@emicmatt>
References: <002f01c6d1ba$df6f3f90$0100a8c0@emicmatt>
Message-ID: <41669544-0CF4-4BA4-8AA6-B9339ABC071E@clearimageonline.com>
No, I want to swap everything including the src. Sorry if that wasn't
clear.
Terry
On Sep 6, 2006, at 9:46 AM, Matt Ludbrook wrote:
> But you said you wanted to swap the IDs. Your initial description
> makes it
> sound like you want to swap everything except the src. In that case
> swapping
> the src would be the easier way of solving your prob.
>
>
> Matt
>
>
>
>
> -----Original Message-----
> From: javascript-bounces at LaTech.edu [mailto:javascript-
> bounces at LaTech.edu]
> On Behalf Of Terry Riegel
> Sent: 06 September 2006 14:35
> To: [JavaScript List]
> Subject: Re: [Javascript] Changing an Objects ID and Name
>
> Sure, but then I would have an ID that represented the wrong image.
> And any subsequent manipulations with that image would be for the
> wrong ID.
>
> Swapping the src tag makes it look like it has swapped, but further
> javascript queries are going to be referencing the wrong ID,
> height, width,
> etc...
>
> Terry
>
>
> On Sep 6, 2006, at 9:11 AM, Mike Dougherty wrote:
>
>> wouldn't it be easier just to swap their src attributes?
>>
>> On Wed, 6 Sep 2006 08:56:00 -0400
>> Terry Riegel wrote:
>>> Hello,
>>> I would like to swap out an image in an application I am writing.
>>> Basically I want to swap two image tags, the trick is I want to swap
>>> their ID and NAME tags also.
>>> The important thing Is I would like to swap all of the attributes
>>> out. i.e. width,height,id,name,src
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.11.7/438 - Release Date:
> 05/09/2006
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Free Edition.
> Version: 7.1.405 / Virus Database: 268.11.7/438 - Release Date:
> 05/09/2006
>
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
From riegel at clearimageonline.com Wed Sep 6 09:44:44 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Wed, 6 Sep 2006 10:44:44 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
Message-ID: <11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
Roger, Jonathan, All,
An example page is at ...
http://clearimageonline.com/pages/start/projects/draganddrop/album.html
I am trying to build the part that will allow the user to swap images
without a page reload. There may be a better way to do it that I am
not thinking of. As far as swapping the drag and drop images I can do
that with Walter Zorn's supplied methods, I need to change the images
in the original HTML.
I will try Jonathan's suggestion as it sounds the most promising.
Thanks,
Terry
On Sep 6, 2006, at 9:52 AM, Roger Roelofs wrote:
> Terry,
>
> Without seeing the page, I can't tell if it would work for sure,
> but, couldn't you just set the className and use css to get the
> display you want?
>
> On Sep 6, 2006, at 9:34 AM, Terry Riegel wrote:
>
>> Sure, but then I would have an ID that represented the wrong
>> image. And any subsequent manipulations with that image would be
>> for the wrong ID.
>>
>> Swapping the src tag makes it look like it has swapped, but
>> further javascript queries are going to be referencing the wrong
>> ID, height, width, etc...
>>
>> Terry
>>
>>
>> On Sep 6, 2006, at 9:11 AM, Mike Dougherty wrote:
>>
>>> wouldn't it be easier just to swap their src attributes?
>>>
>>> On Wed, 6 Sep 2006 08:56:00 -0400
>>> Terry Riegel wrote:
>>>> Hello,
>>>> I would like to swap out an image in an application I am
>>>> writing. Basically I want to swap two image tags, the trick is
>>>> I want to swap their ID and NAME tags also.
>>>> The important thing Is I would like to swap all of the
>>>> attributes out. i.e. width,height,id,name,src
>
> Roger
On Sep 6, 2006, at 10:20 AM, Jonathan Buchanan wrote:
> If you want to swap element locations (which is what you're really
> doing, if I've understood the question correctly), do it directly
> using the DOM instead of fiddling about with element attributes:
>
> function swapNodes(n1, n2)
> {
> var placeHolder = document.createElement("span");
> n1.parentNode.replaceChild(placeHolder, n1);
> n2.parentNode.replaceChild(n1, n2);
> placeHolder.parentNode.replaceChild(n2, placeHolder);
> }
>
> swapNodes(document.getElementById("abc"), document.getElementById
> ("def"));
>
> Regards,
> Jonathan.
From paul at juniperwebcraft.com Wed Sep 6 10:21:48 2006
From: paul at juniperwebcraft.com (Paul Novitski)
Date: Wed, 06 Sep 2006 08:21:48 -0700
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID: <7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
At 9/6/2006 05:56 AM, Terry Riegel wrote:
>I would like to swap out an image in an application I am writing.
>Basically I want to swap two image tags, the trick is I want to swap
>their ID and NAME tags also.
...
>The important thing Is I would like to swap all of the attributes
>out. i.e. width,height,id,name,src
Terry,
What hurdles have you encountered doing exactly what you're wanting
to do? Like others on this list, I'm curious to know if there are
other solutions to whatever your problem might be, but I don't see
why you can't simply do what you want. Attributes including id are
read/write. Swapping them is not difficult. Once you've pointed to
an object, e.g.
var oObj1 = document.getElementById(sId1);
you can change all of its attributes, including id.
Some attributes such as id have named nodes in the DOM:
sSwapAttribute = oObj1.id;
oObj1.id = oObj2.id;
oObj2.id = sSwapAttribute;
http://developer.mozilla.org/en/docs/DOM:element.id
Others need to be access using getAttribute() & setAttribute():
sSwapAttribute = oObj1.getAttribute("foo");
oObj1.setAttribute("foo", oObj2.getAttribute("foo"));
oObj2.setAttribute("foo", sSwapAttribute);
http://developer.mozilla.org/en/docs/DOM:element.getAttribute
http://developer.mozilla.org/en/docs/DOM:element.setAttribute
You can also make good use of attributes() which returns an array of
all attributes of the specified element.
http://developer.mozilla.org/en/docs/DOM:element.attributes
However, this seems like a lot of logic to accomplish a simpler task,
to swap the actual nodes in the DOM, as Jonathan points out.
Philosophically, one wonders: if you swap all the attributes of two
elements, what's left to distinguish them? Their placement in the
HTML markup. Their placement is significant because it determines
their sequence in the markup structure and because it can affect
their visual placement on the page. I would say that in the majority
of cases one can swap two elements in the visual layout using
CSS. If this presentational swapping is your goal, there are
alternative methods you might consider (such as simply swapping their
classNames).
Regards,
Paul
From blmatthews at gmail.com Wed Sep 6 11:05:07 2006
From: blmatthews at gmail.com (Brian L. Matthews)
Date: Wed, 6 Sep 2006 09:05:07 -0700
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID:
>1. With ajax you can change the html between divs.
No. Ajax is the client communicating with a server, usually using
XMLHttpRequest. While lots of applications manipulate the DOM in the
client based upon the result of the request, the two are completely
independent. A page can make XMLHttpRequests and then not change the
page in any way, and JavaScript (or other client side scripting
languages) can modify the page using DOM methods without talking to a
server at all.
>4. Or, you can do it like this via js:
>
>http://xn--ovg.com/a1.php
That page manipulates the DOM using innerHTML (at least the show
part, the don't show part just reloads the page from the server.) It
would also be better done by manipulating the visibility or display
style attributes.
>I need to change the images in the original HTML.
Does this mean if the user reloads the page they should see the
images where they moved them to? Then you'll need to have the page
tell the server what images have swapped, as the script in the client
can't make permanent changes to the page. For actually swapping the
images on the client side, using DOM methods like someone posted
earlier to swap the img nodes is probably the way to go.
Brian
From john at jwarner.com Wed Sep 6 13:34:35 2006
From: john at jwarner.com (John Warner)
Date: Wed, 6 Sep 2006 14:34:35 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
Message-ID: <069901c6d1e3$1ae1e0f0$6b01a8c0@earth>
Paul, let me show my ignorance, but can you 'swap' id attributes in the
fashion below? What I mean is you would seem to have for a moment two
elements with the same ID. The parser 'should' get rather upset with
this situation. Of course I know there is something I'm not seeing here.
John Warner
> -----Original Message-----
> From: javascript-bounces at LaTech.edu
> [mailto:javascript-bounces at LaTech.edu] On Behalf Of Paul Novitski
> Sent: Wednesday, September 06, 2006 11:22 AM
> To: javascript at LaTech.edu
> Subject: Re: [Javascript] Changing an Objects ID and Name
>
>
> At 9/6/2006 05:56 AM, Terry Riegel wrote:
> >I would like to swap out an image in an application I am writing.
> >Basically I want to swap two image tags, the trick is I want to swap
> >their ID and NAME tags also.
> ...
> >The important thing Is I would like to swap all of the
> attributes out.
> >i.e. width,height,id,name,src
>
>
> Terry,
>
> What hurdles have you encountered doing exactly what you're wanting
> to do? Like others on this list, I'm curious to know if
> there are other solutions to whatever your problem might be,
> but I don't see
> why you can't simply do what you want. Attributes including id are
> read/write. Swapping them is not difficult. Once you've pointed to
> an object, e.g.
>
> var oObj1 = document.getElementById(sId1);
>
> you can change all of its attributes, including id.
>
> Some attributes such as id have named nodes in the DOM:
>
> sSwapAttribute = oObj1.id;
> oObj1.id = oObj2.id;
> oObj2.id = sSwapAttribute;
>
http://developer.mozilla.org/en/docs/DOM:element.id
Others need to be access using getAttribute() & setAttribute():
sSwapAttribute = oObj1.getAttribute("foo");
oObj1.setAttribute("foo", oObj2.getAttribute("foo"));
oObj2.setAttribute("foo", sSwapAttribute);
http://developer.mozilla.org/en/docs/DOM:element.getAttribute
http://developer.mozilla.org/en/docs/DOM:element.setAttribute
You can also make good use of attributes() which returns an array of
all attributes of the specified element.
http://developer.mozilla.org/en/docs/DOM:element.attributes
However, this seems like a lot of logic to accomplish a simpler task,
to swap the actual nodes in the DOM, as Jonathan points out.
Philosophically, one wonders: if you swap all the attributes of two
elements, what's left to distinguish them? Their placement in the
HTML markup. Their placement is significant because it determines
their sequence in the markup structure and because it can affect
their visual placement on the page. I would say that in the majority
of cases one can swap two elements in the visual layout using
CSS. If this presentational swapping is your goal, there are
alternative methods you might consider (such as simply swapping their
classNames).
Regards,
Paul
From paul at juniperwebcraft.com Wed Sep 6 16:34:00 2006
From: paul at juniperwebcraft.com (Paul Novitski)
Date: Wed, 06 Sep 2006 14:34:00 -0700
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <069901c6d1e3$1ae1e0f0$6b01a8c0@earth>
References: <7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
<069901c6d1e3$1ae1e0f0$6b01a8c0@earth>
Message-ID: <7.0.1.0.2.20060906133001.05f409e8@juniperwebcraft.com>
At 9/6/2006 11:34 AM, John Warner wrote:
>Paul, let me show my ignorance, but can you 'swap' id attributes in the
>fashion below? What I mean is you would seem to have for a moment two
>elements with the same ID. The parser 'should' get rather upset with
>this situation. Of course I know there is something I'm not seeing here.
Good call. Although I've seen the DOM tolerate elements with
duplicate ids, you're right that we shouldn't rely on it in deference
to future engines that are more strict. Perhaps a better way would be:
sId1 = oObj1.id;
sId2 = oObj2.id;
oObj1.id = '';
oObj2.id = sId1;
oObj1.id = sId2;
Paul
From tedd at sperling.com Wed Sep 6 17:10:52 2006
From: tedd at sperling.com (tedd)
Date: Wed, 6 Sep 2006 18:10:52 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID:
At 9:05 AM -0700 9/6/06, Brian L. Matthews wrote:
>>1. With ajax you can change the html between divs.
>
>No. Ajax is the client communicating with a server, usually using
>XMLHttpRequest. While lots of applications manipulate the DOM in the
>client based upon the result of the request, the two are completely
>independent. A page can make XMLHttpRequests and then not change the
>page in any way, and JavaScript (or other client side scripting
>languages) can modify the page using DOM methods without talking to
>a server at all.
Well maybe I just don't know any better.
I used ajax to send a XMLHttpRequest that changes the html without
reloading the entire page.
The poster said he wanted to swap html from this:
to this:
So, using *his* code, I did the following with ajax:
http://xn--ovg.com/ajax2
Does this not solve the problem? If so, what am I not understanding?
Thanks.
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From tedd at sperling.com Wed Sep 6 17:22:49 2006
From: tedd at sperling.com (tedd)
Date: Wed, 6 Sep 2006 18:22:49 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID:
At 9:05 AM -0700 9/6/06, Brian L. Matthews wrote:
>
>>4. Or, you can do it like this via js:
>>
>>http://xn--ovg.com/a1.php
>
>That page manipulates the DOM using innerHTML (at least the show
>part, the don't show part just reloads the page from the server.)
The "don't show part" doesn't do anything of the sort -- it is simply
a wrapper for the code shown. The code shown ("the show part") does
the work -- that's the reason why it's shown.
>It would also be better done by manipulating the visibility or
>display style attributes.
Does this --
3. With css you can use the visibility attribute showing both
combinations and then change visibility/hidden with a style switcher.
-- not say that?
Again, what is it that I'm not getting here? Is it communication with
the server? Must the solution not contact the server, is that it?
tedd
--
-------
http://sperling.com http://ancientstones.com http://earthstones.com
From scott at randomchaos.com Wed Sep 6 17:42:12 2006
From: scott at randomchaos.com (Scott Reynen)
Date: Wed, 6 Sep 2006 17:42:12 -0500
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
Message-ID: <7A41BBF4-BD99-4EAA-91F9-B06A552823C0@randomchaos.com>
On Sep 6, 2006, at 5:10 PM, tedd wrote:
> At 9:05 AM -0700 9/6/06, Brian L. Matthews wrote:
>>> 1. With ajax you can change the html between divs.
>>
>> No. Ajax is the client communicating with a server, usually using
>> XMLHttpRequest. While lots of applications manipulate the DOM in
>> the client based upon the result of the request, the two are
>> completely independent. A page can make XMLHttpRequests and then
>> not change the page in any way, and JavaScript (or other client
>> side scripting languages) can modify the page using DOM methods
>> without talking to a server at all.
>
> Well maybe I just don't know any better.
>
> I used ajax to send a XMLHttpRequest that changes the html without
> reloading the entire page.
No, you didn't. You used AJAX/XMLHttpRequest to fetch content from
the server. You used DOM manipulation to change HTML. That you used
both in the same script does not in any way contradict what Brian
said: the two are completely independent. AJAX is not the same as
DOM manipulation.
On Sep 6, 2006, at 5:22 PM, tedd wrote:
> Again, what is it that I'm not getting here? Is it communication
> with the server? Must the solution not contact the server, is that it?
Why would you use AJAX here? It doesn't appear to solve the problem
at hand. If you're just using AJAX because you want to use AJAX,
that's fine, but presenting it as a solution to a problem it doesn't
actually solve is likely to confuse people. The problem of swapping
images is solved with DOM manipulation. Anything you add on top of
that is solving a different problem -- assuming it solves a problem
at all.
Peace,
Scott
From riegel at clearimageonline.com Wed Sep 6 23:21:38 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Thu, 7 Sep 2006 00:21:38 -0400
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
Message-ID: <3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
Paul, if you have a look at my example page I can explain from that.
http://clearimageonline.com/pages/start/projects/draganddrop/album.html
On this page you can drag around images and if they are not on a drop
zone they will snap back, if they are on a drop zone they will zoom
down to it. Also if you click outside an image it will deselect all
images. What I am trying to accomplish is to allow a user (when
dragging 1 image) to drop it and it will get inserted into the spot
and all the other images will ripple to give it room. For every image
on the page there is the original image and a cloned image (via
Walter Zorn's drag and drop script). I can swap the cloned images
using the methods provided by Walter Zorn.
I have implemented the function presented by Jonathan Buckman (Thanks
Jonathan) to simply swap out the objects. So I am able to swap images
around. I have the image swap working, I expect to have the final
drop/ripple working later tomorrow. I was able to get a lot working
today.
I modified it slightly to include the type of node being swapped.
function swapNodes(n1, n2, k)
{
var placeHolder = document.createElement(k);
n1.parentNode.replaceChild(placeHolder, n1);
n2.parentNode.replaceChild(n1, n2);
placeHolder.parentNode.replaceChild(n2, placeHolder);
}
Is there some type of cleanup needed to remove the temporary node
(placeHolder)? Or is it local to the function and gets removed
automatically?
On Sep 6, 2006, at 11:21 AM, Paul Novitski wrote:
> At 9/6/2006 05:56 AM, Terry Riegel wrote:
>> I would like to swap out an image in an application I am writing.
>> Basically I want to swap two image tags, the trick is I want to swap
>> their ID and NAME tags also.
> ...
>> The important thing Is I would like to swap all of the attributes
>> out. i.e. width,height,id,name,src
>
>
> Terry,
>
> What hurdles have you encountered doing exactly what you're wanting
> to do? Like others on this list, I'm curious to know if there are
> other solutions to whatever your problem might be, but I don't see
> why you can't simply do what you want. Attributes including id are
> read/write. Swapping them is not difficult. Once you've pointed
> to an object, e.g.
>
> var oObj1 = document.getElementById(sId1);
>
> you can change all of its attributes, including id.
>
> Some attributes such as id have named nodes in the DOM:
>
> sSwapAttribute = oObj1.id;
> oObj1.id = oObj2.id;
> oObj2.id = sSwapAttribute;
>
> http://developer.mozilla.org/en/docs/DOM:element.id
>
> Others need to be access using getAttribute() & setAttribute():
>
> sSwapAttribute = oObj1.getAttribute("foo");
> oObj1.setAttribute("foo", oObj2.getAttribute("foo"));
> oObj2.setAttribute("foo", sSwapAttribute);
>
> http://developer.mozilla.org/en/docs/DOM:element.getAttribute
> http://developer.mozilla.org/en/docs/DOM:element.setAttribute
>
> You can also make good use of attributes() which returns an array
> of all attributes of the specified element.
> http://developer.mozilla.org/en/docs/DOM:element.attributes
>
> However, this seems like a lot of logic to accomplish a simpler
> task, to swap the actual nodes in the DOM, as Jonathan points out.
>
> Philosophically, one wonders: if you swap all the attributes of two
> elements, what's left to distinguish them? Their placement in the
> HTML markup. Their placement is significant because it determines
> their sequence in the markup structure and because it can affect
> their visual placement on the page. I would say that in the
> majority of cases one can swap two elements in the visual layout
> using CSS. If this presentational swapping is your goal, there are
> alternative methods you might consider (such as simply swapping
> their classNames).
>
> Regards,
> Paul
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
From paul at juniperwebcraft.com Thu Sep 7 00:06:31 2006
From: paul at juniperwebcraft.com (Paul Novitski)
Date: Wed, 06 Sep 2006 22:06:31 -0700
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
<3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
Message-ID: <7.0.1.0.2.20060906215557.04458238@juniperwebcraft.com>
At 9/6/2006 09:21 PM, Terry Riegel wrote:
>http://clearimageonline.com/pages/start/projects/draganddrop/album.html
...
>function swapNodes(n1, n2, k)
>{
> var placeHolder = document.createElement(k);
> n1.parentNode.replaceChild(placeHolder, n1);
> n2.parentNode.replaceChild(n1, n2);
> placeHolder.parentNode.replaceChild(n2, placeHolder);
>}
>
>Is there some type of cleanup needed to remove the temporary node
>(placeHolder)? Or is it local to the function and gets removed
>automatically?
Since you're creating the placeholder element in the document, I'm
sure it's effectively global and will persist beyond the local
function. I'd remove it just to be safe. It might take a huge
amount of playing around to challenge local memory, but it seems more
elegant to clean up after each iteration.
By the way, nice user interface, Terry! Good start! I'll look
forward to seeing your application when it's finished.
I have just two suggestions that might already be on your to-do list:
first that when dragging multiple images you show them all and not
just the one where dragging was begun, and second that you represent
the albums graphically, filling them with micro-thumbnails as
pictures are dragged into them. It wasn't immediately clear to me
where to drag the pictures, and it would be cool if this kind of GUI
could be intuitively obvious.
Regards,
Paul
From jonathan.buchanan at gmail.com Thu Sep 7 01:07:52 2006
From: jonathan.buchanan at gmail.com (Jonathan Buchanan)
Date: Thu, 7 Sep 2006 07:07:52 +0100
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
<3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
Message-ID:
On 9/7/06, Terry Riegel wrote:
>
> I modified it slightly to include the type of node being swapped.
>
> function swapNodes(n1, n2, k)
> {
> var placeHolder = document.createElement(k);
> n1.parentNode.replaceChild(placeHolder, n1);
> n2.parentNode.replaceChild(n1, n2);
> placeHolder.parentNode.replaceChild(n2, placeHolder);
> }
>
> Is there some type of cleanup needed to remove the temporary node
> (placeHolder)? Or is it local to the function and gets removed
> automatically?
As placeHolder is declared using "var", it's local to the function.
When the function returns, placeHolder is not attached to the document
any more and there are no other references to it hanging around, so it
should get removed automatically.
FWIW, the type of element used for the placeHolder doesn't really matter.
Jonathan.
From lists at dwsasia.com Thu Sep 7 02:58:00 2006
From: lists at dwsasia.com (Peter Lauri)
Date: Thu, 7 Sep 2006 14:58:00 +0700
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
Message-ID: <20060907075829.C3AC3132F1@smtp2.LaTech.edu>
I thought it was the opposite so that something declared as var will be
"global". For example:
var thisVariable = 50;
thisNoVariable = 5;
trythis();
trythisno();
function trythis() {
alert(thisVariable);
}
function trythisno() {
alert(thisNoVariable);
}
I have not tested this, but I do believe there will be an error in the
function trythisno().
/Peter
-----Original Message-----
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu]
On Behalf Of Jonathan Buchanan
Sent: Thursday, September 07, 2006 1:08 PM
To: [JavaScript List]
Subject: Re: [Javascript] Changing an Objects ID and Name
On 9/7/06, Terry Riegel wrote:
>
> I modified it slightly to include the type of node being swapped.
>
> function swapNodes(n1, n2, k)
> {
> var placeHolder = document.createElement(k);
> n1.parentNode.replaceChild(placeHolder, n1);
> n2.parentNode.replaceChild(n1, n2);
> placeHolder.parentNode.replaceChild(n2, placeHolder);
> }
>
> Is there some type of cleanup needed to remove the temporary node
> (placeHolder)? Or is it local to the function and gets removed
> automatically?
As placeHolder is declared using "var", it's local to the function.
When the function returns, placeHolder is not attached to the document
any more and there are no other references to it hanging around, so it
should get removed automatically.
FWIW, the type of element used for the placeHolder doesn't really matter.
Jonathan.
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
From jonathan.buchanan at gmail.com Thu Sep 7 04:16:26 2006
From: jonathan.buchanan at gmail.com (Jonathan Buchanan)
Date: Thu, 7 Sep 2006 10:16:26 +0100
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <20060907075829.C3AC3132F1@smtp2.LaTech.edu>
References:
<20060907075829.C3AC3132F1@smtp2.LaTech.edu>
Message-ID:
> I thought it was the opposite so that something declared as var will be
> "global". For example:
>
> var thisVariable = 50;
> thisNoVariable = 5;
>
> trythis();
>
> trythisno();
>
> function trythis() {
> alert(thisVariable);
> }
>
> function trythisno() {
> alert(thisNoVariable);
> }
>
> I have not tested this, but I do believe there will be an error in the
> function trythisno().
>
> /Peter
Have a look at the documentation for the var operator:
http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Statements:var
In your example, you've created two variables in the global scope, so
both functions will work. As you can read in the documentation, it
doesn't matter whether you use "var" or not when declaring functions
in the global scope - you're already in the global scope, so by using
the var operator you're just explicitly saying "I belong to the
current scope, which is the global scope" (as with thisVariable)
rather than saying "I belong to the default scope, which is the global
scope" (as with thisNoVariable).
What we're really interested in is the effect var has in a function.
If you don't use the var operator, any variables you declare in a
function get the default scope, which is the global scope. This is why
it's important to use var to declare local variables in functions.
function testScoping1()
{
cheese = 5;
}
testScoping1();
alert(typeof(cheese)); // Produces "number" - the cheese variable is
now in the global scope!
function testScoping2()
{
var toast = 10;
}
testScoping2();
alert(typeof(toast)); // Produces "undefined" - the toast variable was
local to the function during its execution
Jonathan.
From paul at juniperwebcraft.com Thu Sep 7 05:33:35 2006
From: paul at juniperwebcraft.com (Paul Novitski)
Date: Thu, 07 Sep 2006 03:33:35 -0700
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
<3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
Message-ID: <7.0.1.0.2.20060907032250.022014b0@juniperwebcraft.com>
At 9/6/2006 11:07 PM, Jonathan Buchanan wrote:
>On 9/7/06, Terry Riegel wrote:
>>
>>I modified it slightly to include the type of node being swapped.
>>
>>function swapNodes(n1, n2, k)
>>{
>> var placeHolder = document.createElement(k);
>> n1.parentNode.replaceChild(placeHolder, n1);
>> n2.parentNode.replaceChild(n1, n2);
>> placeHolder.parentNode.replaceChild(n2, placeHolder);
>>}
>>
>>Is there some type of cleanup needed to remove the temporary node
>>(placeHolder)? Or is it local to the function and gets removed
>>automatically?
>
>As placeHolder is declared using "var", it's local to the function.
>When the function returns, placeHolder is not attached to the document
>any more and there are no other references to it hanging around, so it
>should get removed automatically.
Jonathan, I suspect you're wrong on this point. While I agree that
the variable 'placeHolder' is local to the function 'swapNodes()' and
will be cleared when the function terminates, surely when you invoke
the DOM method createElement() you're creating a new element IN THE
DOM which has got to be about as global as you can get in a script
running in the context of the Document Object Model.
Am I wrong about this? Does the createElement() method return a node
object that isn't actually part of the DOM and doesn't persist when
the calling function returns?
Regards,
Paul
From nick at nickfitz.co.uk Thu Sep 7 05:54:18 2006
From: nick at nickfitz.co.uk (Nick Fitzsimons)
Date: Thu, 7 Sep 2006 11:54:18 +0100
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <7.0.1.0.2.20060907032250.022014b0@juniperwebcraft.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
<3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
<7.0.1.0.2.20060907032250.022014b0@juniperwebcraft.com>
Message-ID: <253B6914-0FE8-462F-861E-D9148EC20C05@nickfitz.co.uk>
On 7 Sep 2006, at 11:33, Paul Novitski wrote:
> At 9/6/2006 11:07 PM, Jonathan Buchanan wrote:
>> On 9/7/06, Terry Riegel wrote:
>>>
>>> I modified it slightly to include the type of node being swapped.
>>>
>>> function swapNodes(n1, n2, k)
>>> {
>>> var placeHolder = document.createElement(k);
>>> n1.parentNode.replaceChild(placeHolder, n1);
>>> n2.parentNode.replaceChild(n1, n2);
>>> placeHolder.parentNode.replaceChild(n2, placeHolder);
>>> }
>>>
>>> Is there some type of cleanup needed to remove the temporary node
>>> (placeHolder)? Or is it local to the function and gets removed
>>> automatically?
>>
>> As placeHolder is declared using "var", it's local to the function.
>> When the function returns, placeHolder is not attached to the
>> document
>> any more and there are no other references to it hanging around,
>> so it
>> should get removed automatically.
>
>
> Jonathan, I suspect you're wrong on this point. While I agree that
> the variable 'placeHolder' is local to the function 'swapNodes()'
> and will be cleared when the function terminates, surely when you
> invoke the DOM method createElement() you're creating a new element
> IN THE DOM which has got to be about as global as you can get in a
> script running in the context of the Document Object Model.
> Am I wrong about this? Does the createElement() method return a
> node object that isn't actually part of the DOM and doesn't persist
> when the calling function returns?
>
If you examine a node returned by createElement you will see that it
has no parentNode; it isn't part of the DOM tree until it is
explicitly inserted into the tree. In this case it is inserted and
then removed, so the only remaining reference to it is in the local
variable. Therefore it should be available for garbage collection
when the function terminates.
Cheers,
Nick.
--
Nick Fitzsimons
http://www.nickfitz.co.uk/
From jonathan.buchanan at gmail.com Thu Sep 7 06:10:57 2006
From: jonathan.buchanan at gmail.com (Jonathan Buchanan)
Date: Thu, 7 Sep 2006 12:10:57 +0100
Subject: [Javascript] Changing an Objects ID and Name
In-Reply-To: <7.0.1.0.2.20060907032250.022014b0@juniperwebcraft.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<7.0.1.0.2.20060906075810.05d65ff8@juniperwebcraft.com>
<3B79390A-C187-4865-A0E5-E4F23A4913E2@clearimageonline.com>
<7.0.1.0.2.20060907032250.022014b0@juniperwebcraft.com>
Message-ID:
On 9/7/06, Paul Novitski wrote:
> Jonathan, I suspect you're wrong on this point. While I agree that
> the variable 'placeHolder' is local to the function 'swapNodes()' and
> will be cleared when the function terminates, surely when you invoke
> the DOM method createElement() you're creating a new element IN THE
> DOM which has got to be about as global as you can get in a script
> running in the context of the Document Object Model.
>
> Am I wrong about this? Does the createElement() method return a node
> object that isn't actually part of the DOM and doesn't persist when
> the calling function returns?
>
> Regards,
> Paul
Correct - the element returned from the createElement function isn't
actually in the document's DOM tree until you insert it. The element
holds a reference to its ownerDocument, but the ownerDocument doesn't
hold a reference to the element. The situation is the same after the
element has been inserted and then removed from the DOM tree. So when
the function terminates, placeHolder is a locally scoped variable to
which there are no references.
Jonathan.
From riegel at clearimageonline.com Thu Sep 7 09:48:33 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Thu, 7 Sep 2006 10:48:33 -0400
Subject: [Javascript] How do I build a simple array
In-Reply-To: <11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
Message-ID:
Hello All,
How do I remove the first item from an array?
Terry
From leeu at cfl.rr.com Thu Sep 7 10:05:08 2006
From: leeu at cfl.rr.com (Lee Underwood)
Date: Thu, 07 Sep 2006 11:05:08 -0400
Subject: [Javascript] How do I build a simple array
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
Message-ID: <7.0.1.0.0.20060907110430.01fc5f00@cfl.rr.com>
You can do that using the shift() method. Think of it as taking the
first element and "shifting" it to the left, out of the array. You
can do it using the following format.
var chevCar = new Array("Nova","Impala","Corvette");
alert("The original lineup is " + chevCar);
chevCar.shift();
alert("The new lineup is " + chevCar);
The first part of the script works just like the previous above.
However, after displaying all of the elements, it removes the first
one and displays an alert window with the remaining two elements.
(See: http://www.webreference.com/programming/javascript/diaries/13/4.html)
Lee Underwood
Jupitermedia Corporation
Managing Editor
WebDeveloper.com | ScriptSearch | JavaScript Source | TheCounter | TheGuestbook
Associate Editor
WebReference.com
On 9/7/2006 10:48 AM, Terry Riegel wrote:
........................................................
>Hello All,
>
>How do I remove the first item from an array?
>
>Terry
........................................................
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From riegel at clearimageonline.com Thu Sep 7 10:06:53 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Thu, 7 Sep 2006 11:06:53 -0400
Subject: [Javascript] How do I build a simple array
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
Message-ID: <75EA554D-22CF-4270-8B70-35DE0D6458C4@clearimageonline.com>
Found it,
array.shift()
Terry
On Sep 7, 2006, at 10:48 AM, Terry Riegel wrote:
> Hello All,
>
> How do I remove the first item from an array?
>
> Terry
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
From riegel at clearimageonline.com Thu Sep 7 10:13:08 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Thu, 7 Sep 2006 11:13:08 -0400
Subject: [Javascript] I have hit a brick wall
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
Message-ID: <45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
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
From jonathan.buchanan at gmail.com Thu Sep 7 10:17:56 2006
From: jonathan.buchanan at gmail.com (Jonathan Buchanan)
Date: Thu, 7 Sep 2006 16:17:56 +0100
Subject: [Javascript] I have hit a brick wall
In-Reply-To: <45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
Message-ID:
On 9/7/06, Terry Riegel 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.
From riegel at clearimageonline.com Thu Sep 7 10:33:44 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Thu, 7 Sep 2006 11:33:44 -0400
Subject: [Javascript] I have hit a brick wall
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
Message-ID: <794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
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 On 9/7/06, Terry Riegel 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
From scott at randomchaos.com Thu Sep 7 11:16:43 2006
From: scott at randomchaos.com (Scott Reynen)
Date: Thu, 7 Sep 2006 11:16:43 -0500
Subject: [Javascript] I have hit a brick wall
In-Reply-To: <794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<20060904090646.GA26749@us-lot.org>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
Message-ID: <49D7BA95-F897-46CF-81C8-4E3A57CC4C58@randomchaos.com>
On Sep 7, 2006, at 10:33 AM, Terry Riegel wrote:
> 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 {
> 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);
> }
How about this (untested):
function bubbleUpNodes(a) // where a is array of IDs
{
for ( x=1; x
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
Message-ID:
On 9/7/06, Terry Riegel wrote:
> 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 {
> 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
The implementation of this really depends on the specifics of how the
document is structured. Moving each and every node one at a time is a
last resort, as you can structure your document in a way which makes
it easy to manipulate as you desire.
For example, if the nodes in question are arranged like so:
parent
|-- child1
|-- child2
|-- child3
...then moving child1 to the end is as simple as
child1.parentNode.appendChild(child1).
Similarly, if each node you're interested in is wrapped in its own
container element, but the container elements are the only children of
some common parent element, you do exactly the same, but operating on
child1.parentNode instead of child1.
Is for the same page as before?
Jonathan.
From riegel at clearimageonline.com Thu Sep 7 12:48:48 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Thu, 7 Sep 2006 13:48:48 -0400
Subject: [Javascript] I have hit a brick wall
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
Message-ID: <4F9B4FC7-81F3-450C-BEC0-F90C79ADC583@clearimageonline.com>
Basically I have a bunch of Images that a user can drag one to
another location and when they drop the image it detects where they
dropped it and then it generates a list of the images that need to be
moved. I am now at the point where I need to move the images. I have
already implemented Scott's BubbleUpNodes() function and it seems to
be working so far. I am not sure if there is an easier way to do this.
Now I just need to communicate these changes back to the server via
AJAX.
Thanks,
Terry Riegel
On Sep 7, 2006, at 12:18 PM, Jonathan Buchanan wrote:
> On 9/7/06, Terry Riegel wrote:
>> 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> {
>> 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
>
> The implementation of this really depends on the specifics of how the
> document is structured. Moving each and every node one at a time is a
> last resort, as you can structure your document in a way which makes
> it easy to manipulate as you desire.
>
> For example, if the nodes in question are arranged like so:
>
> parent
> |-- child1
> |-- child2
> |-- child3
>
> ...then moving child1 to the end is as simple as
> child1.parentNode.appendChild(child1).
>
> Similarly, if each node you're interested in is wrapped in its own
> container element, but the container elements are the only children of
> some common parent element, you do exactly the same, but operating on
> child1.parentNode instead of child1.
>
> Is for the same page as before?
>
> Jonathan.
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
From joel.goldstick at columbuswebmakers.com Thu Sep 7 15:06:40 2006
From: joel.goldstick at columbuswebmakers.com (joel.goldstick at columbuswebmakers.com)
Date: Thu, 07 Sep 2006 16:06:40 -0400
Subject: [Javascript] I have hit a brick wall
In-Reply-To:
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu> <20060904090646.GA26749@us-lot.org> <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com> <5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com> <0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com> <11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com> <45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
Message-ID: <45007BD0.1020606@columbuswebmakers.com>
>
> i.push(i.shift());
>
While the looping methods outlined may be easier to understand, this
line of code is a gem! My guess is that it also runs faster. No need
to know how many items in the array either.
So, if this looks strange, do a little study on stacks and lists. These
are long time standard constructs for those who studied programming in
college courses, but are most likely missed by the many who are learning
to code by the seat of their pants!
--
Joel Goldstick
www.columbuswebmakers.com
From scott at randomchaos.com Thu Sep 7 16:09:44 2006
From: scott at randomchaos.com (Scott Reynen)
Date: Thu, 7 Sep 2006 16:09:44 -0500
Subject: [Javascript] I have hit a brick wall
In-Reply-To: <45007BD0.1020606@columbuswebmakers.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu> <20060904090646.GA26749@us-lot.org> <4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com> <5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com> <0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com> <11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com> <45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<45007BD0.1020606@columbuswebmakers.com>
Message-ID:
On Sep 7, 2006, at 3:06 PM, joel.goldstick at columbuswebmakers.com wrote:
>> i.push(i.shift());
> While the looping methods outlined may be easier to understand,
> this line of code is a gem! My guess is that it also runs faster.
> No need to know how many items in the array either.
>
> So, if this looks strange, do a little study on stacks and lists.
> These are long time standard constructs for those who studied
> programming in college courses, but are most likely missed by the
> many who are learning to code by the seat of their pants!
While the above code is ideal for arrays, DOM nodes are in a tree,
not an array. The general concept could still be applied if you know
in advance the exact structure of the DOM tree, as Jonathon said, but
that doesn't seem to be the case for this particular problem.
Peace,
Scott
From riegel at clearimageonline.com Fri Sep 8 14:17:58 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Fri, 8 Sep 2006 15:17:58 -0400
Subject: [Javascript] Walking the DOM
In-Reply-To: <4F9B4FC7-81F3-450C-BEC0-F90C79ADC583@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
<4F9B4FC7-81F3-450C-BEC0-F90C79ADC583@clearimageonline.com>
Message-ID: <625F77F1-D8BD-4F73-86AF-DBB54AE9F8B0@clearimageonline.com>
If I have the following markup...
and... in my javascript I have...
o=document.getElementById('album01');
How do I reference (with the intent of changing) the content of the
anchor? My goal is to replace the text with an updated number from
the server, but I need a method to replace the text. As a side
question should I be using innerHTML, or is there a better method. If
anyone is using prototype and knows of a method through that library
that would be helpful.
Thanks,
Terry
From peter at brunone.com Fri Sep 8 14:49:10 2006
From: peter at brunone.com (Peter Brunone)
Date: Fri, 8 Sep 2006 12:49:10 -0700
Subject: [Javascript] Walking the DOM
Message-ID:
Wouldn't that just be o.childNodes[0].innerHTML ?
Of course I may have misunderstood the question...
From: Terry Riegel riegel at clearimageonline.com
If I have the following markup...
My Favorite
Photos (58)
and... in my javascript I have...
o=document.getElementById('album01');
How do I reference (with the intent of changing) the content of the
anchor? My goal is to replace the text with an updated number from
the server, but I need a method to replace the text. As a side
question should I be using innerHTML, or is there a better method. If
anyone is using prototype and knows of a method through that library
that would be helpful.
Thanks,
Terry
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From mwarden at gmail.com Fri Sep 8 17:33:24 2006
From: mwarden at gmail.com (Matt Warden)
Date: Fri, 8 Sep 2006 18:33:24 -0400
Subject: [Javascript] Walking the DOM
In-Reply-To: <625F77F1-D8BD-4F73-86AF-DBB54AE9F8B0@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
<4F9B4FC7-81F3-450C-BEC0-F90C79ADC583@clearimageonline.com>
<625F77F1-D8BD-4F73-86AF-DBB54AE9F8B0@clearimageonline.com>
Message-ID:
On 9/8/06, Terry Riegel wrote:
> If I have the following markup...
>
>
>
>
>
> and... in my javascript I have...
>
> o=document.getElementById('album01');
>
>
>
> How do I reference (with the intent of changing) the content of the
> anchor? My goal is to replace the text with an updated number from
> the server, but I need a method to replace the text. As a side
> question should I be using innerHTML, or is there a better method. If
> anyone is using prototype and knows of a method through that library
> that would be helpful.
var li = document.getElementById('album01');
var anchor = li.firstChild;
var textNode = anchor.firstChild;
http://www.devguru.com/technologies/xmldom/QuickRef/node_replaceChild.html
--
Matt Warden
Cleveland, OH, USA
http://mattwarden.com
This email proudly and graciously contributes to entropy.
From trojani2000 at hotmail.com Fri Sep 8 19:17:42 2006
From: trojani2000 at hotmail.com (Troy III Ajnej)
Date: Sat, 9 Sep 2006 00:17:42 +0000
Subject: [Javascript] Walking the DOM
Message-ID:
But you don't need to change the href="album01.html".
Is that correct?~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> From: riegel at clearimageonline.com> Subject: [Javascript] Walking the DOM> Date: Fri, 8 Sep 2006 15:17:58 -0400> To: javascript at LaTech.edu> > If I have the following markup...> >
> > > > and... in my javascript I have...> > o=document.getElementById('album01');> > > > How do I reference (with the intent of changing) the content of the > anchor? My goal is to replace the text with an updated number from > the server, but I need a method to replace the text. As a side > question should I be using innerHTML, or is there a better method. If > anyone is using prototype and knows of a method through that library > that would be helpful.> > > > Thanks,> > Terry> _______________________________________________> Javascript mailing list> Javascript at LaTech.edu> https://lists.LaTech.edu/mailman/listinfo/javascript
_________________________________________________________________
Use Messenger to talk to your IM friends, even those on Yahoo!
http://ideas.live.com/programpage.aspx?versionId=7adb59de-a857-45ba-81cc-685ee3e858fe
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From riegel at clearimageonline.com Fri Sep 8 23:33:38 2006
From: riegel at clearimageonline.com (Terry Riegel)
Date: Sat, 9 Sep 2006 00:33:38 -0400
Subject: [Javascript] Walking the DOM
In-Reply-To:
References:
Message-ID: <85314384-22AF-433D-8440-BAE8F05F759D@clearimageonline.com>
Correct
On Sep 8, 2006, at 8:17 PM, Troy III Ajnej wrote:
> But you don't need to change the href="album01.html".
> Is that correct?
>
>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> Troy III
> progressive art enterprise
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
>
>
> > From: riegel at clearimageonline.com
> > Subject: [Javascript] Walking the DOM
> > Date: Fri, 8 Sep 2006 15:17:58 -0400
> > To: javascript at LaTech.edu
> >
> > If I have the following markup...
> >
> >
> >
> >
> >
> > and... in my javascript I have...
> >
> > o=document.getElementById('album01');
> >
> >
> >
> > How do I reference (with the intent of changing) the content of the
> > anchor? My goal is to replace the text with an updated number from
> > the server, but I need a method to replace the text. As a side
> > question should I be using innerHTML, or is there a better
> method. If
> > anyone is using prototype and knows of a method through that library
> > that would be helpful.
> >
> >
> >
> > Thanks,
> >
> > Terry
> > _______________________________________________
> > Javascript mailing list
> > Javascript at LaTech.edu
> > https://lists.LaTech.edu/mailman/listinfo/javascript
>
>
> Use Messenger to talk to your IM friends, even those on Yahoo! Talk
> now!
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From paul at juniperwebcraft.com Sat Sep 9 00:25:57 2006
From: paul at juniperwebcraft.com (Paul Novitski)
Date: Fri, 08 Sep 2006 22:25:57 -0700
Subject: [Javascript] Walking the DOM
In-Reply-To: <625F77F1-D8BD-4F73-86AF-DBB54AE9F8B0@clearimageonline.com>
References: <20060904021333.DBA4D12003@smtp2.LaTech.edu>
<4E4A2D2F-8FEC-4DF4-A2B7-F268F5E973A4@clearimageonline.com>
<5014EE81-8D55-44F8-9016-B5405EFF8A0F@clearimageonline.com>
<0F89F915-CCE4-4E3D-A16A-5E9E4847E486@datacompusa.com>
<11A63BA1-3627-40E4-BF50-55611B9F506F@clearimageonline.com>
<45EEF86E-8A5B-4B21-9F7F-6D1842DA70BC@clearimageonline.com>
<794B2F6D-DEF2-4059-A01E-1AFDA9E46794@clearimageonline.com>
<4F9B4FC7-81F3-450C-BEC0-F90C79ADC583@clearimageonline.com>
<625F77F1-D8BD-4F73-86AF-DBB54AE9F8B0@clearimageonline.com>
Message-ID: <7.0.1.0.2.20060908220618.05f31560@juniperwebcraft.com>
At 9/8/2006 12:17 PM, Terry Riegel wrote:
>If I have the following markup...
>
>
>
>and... in my javascript I have...
>
> o=document.getElementById('album01');
>
>How do I reference (with the intent of changing) the content of the
>anchor? My goal is to replace the text
At 9/8/2006 12:49 PM, Peter Brunone wrote:
>Wouldn't that just be o.childNodes[0].innerHTML ?
At 9/8/2006 03:33 PM, Matt Warden wrote:
>var li = document.getElementById('album01');
>var anchor = li.firstChild;
>var textNode = anchor.firstChild;
Part of the question will always be: how stable is your markup? For
example, if you or anyone else ever changes the HTML by inserting a
carriage return between the LI tag and the A, then I believe the
firstChild and the first childNode of LI would be a text node (the
carriage return) and the anchor would be its next sibling. Perhaps
safer would be:
o=document.getElementById('album01');
var aAnchors = o.getElementsByTagName("A");
if (aAnchors.length != 1) return alert("Help! Kwazy
unexpected markup!");
Then your one and only expected anchor is aAnchors[0].
Again, if the contents of the anchor is a single text string then it
will indeed be the firstChild, but if anyone ever inserts a SPAN or
EM then you'll have two or more childNodes.
In the Gecko DOM Reference it suggests an iterative approach to
removing all the children of a parent:
// remove all children from element
var element = document.getElementById("top");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
http://developer.mozilla.org/en/docs/DOM:element.removeChild#Example
With respect to innerHTML, the reference says: "Though not actually
a part of the W3C DOM specification, this property provides a simple
way to completely replace the contents of an element. ... As there is
no public specification for this property, implementations differ
widely. For example, when text is entered into a text input, IE will
change the value attribute of the input's innerHTML property but
Gecko browsers do not."
http://developer.mozilla.org/en/docs/DOM:element.innerHTML#Notes
I take that to mean that using removeChild is the safer course,
although you might get away with using innerHTML with few complaints.
Paul
From peter at brunone.com Sat Sep 9 00:38:54 2006
From: peter at brunone.com (Peter Brunone)
Date: Fri, 8 Sep 2006 22:38:54 -0700
Subject: [Javascript] Walking the DOM
Message-ID: <2adff6087a52416e9230b186ed883074@brunone.com>
Ah so.
I stand corrected.
Funny, too, since I've taken to using the getElementsByTagName approach lately anyway...
From: Paul Novitski paul at juniperwebcraft.com
At 9/8/2006 12:17 PM, Terry Riegel wrote:
>If I have the following markup...
>
>
My Favorite
>Photos (58)
>
>and... in my javascript I have...
>
> o=document.getElementById('album01');
>
>How do I reference (with the intent of changing) the content of the
>anchor? My goal is to replace the text
At 9/8/2006 12:49 PM, Peter Brunone wrote:
>Wouldn't that just be o.childNodes[0].innerHTML ?
At 9/8/2006 03:33 PM, Matt Warden wrote:
>var li = document.getElementById('album01');
>var anchor = li.firstChild;
>var textNode = anchor.firstChild;
Part of the question will always be: how stable is your markup? For
example, if you or anyone else ever changes the HTML by inserting a
carriage return between the LI tag and the A, then I believe the
firstChild and the first childNode of LI would be a text node (the
carriage return) and the anchor would be its next sibling. Perhaps
safer would be:
o=document.getElementById('album01');
var aAnchors = o.getElementsByTagName("A");
if (aAnchors.length != 1) return alert("Help! Kwazy
unexpected markup!");
Then your one and only expected anchor is aAnchors[0].
Again, if the contents of the anchor is a single text string then it
will indeed be the firstChild, but if anyone ever inserts a SPAN or
EM then you'll have two or more childNodes.
In the Gecko DOM Reference it suggests an iterative approach to
removing all the children of a parent:
// remove all children from element
var element = document.getElementById("top");
while (element.firstChild) {
element.removeChild(element.firstChild);
}
http://developer.mozilla.org/en/docs/DOM:element.removeChild#Example
With respect to innerHTML, the reference says: "Though not actually
a part of the W3C DOM specification, this property provides a simple
way to completely replace the contents of an element. ... As there is
no public specification for this property, implementations differ
widely. For example, when text is entered into a text input, IE will
change the value attribute of the input's innerHTML property but
Gecko browsers do not."
http://developer.mozilla.org/en/docs/DOM:element.innerHTML#Notes
I take that to mean that using removeChild is the safer course,
although you might get away with using innerHTML with few complaints.
Paul
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From asureshkumar_1983 at yahoo.co.in Sat Sep 9 00:55:03 2006
From: asureshkumar_1983 at yahoo.co.in (suresh kumar)
Date: Sat, 9 Sep 2006 06:55:03 +0100 (BST)
Subject: [Javascript] virual memory proeblem
Message-ID: <20060909055503.96452.qmail@web8614.mail.in.yahoo.com>
Hi,
I am facing one problem in my project.i am working in myadtv project that will display ads one by one in big LCD screen .
suppose if i want display 100 ads one by one for a particular duration,after displaying the 100 th ad again it will start from 1 ad and goes in a loop until the user closes the browser.
my problem is ,if its runs for continuously more than 10 hours if am displaying the message as
" your system virtual memory is too low,windows is increasing the size of the virtual memory paging file ,during this process memory request for some application may be denied". i can't understand this error message ,can any one tell me what this errror message.
the logc behind our code - we are using javascript "imagepreloader() function to load the ads in the browser cache once it gets loaded then it will start displaying one by one.
---------------------------------
Find out what India is talking about on - Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. Get it NOW
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From Alex.Turner at Project-Network.com Sat Sep 9 04:04:02 2006
From: Alex.Turner at Project-Network.com (Alex Turner)
Date: Sat, 9 Sep 2006 10:04:02 +0100
Subject: [Javascript] virual memory proeblem
In-Reply-To: <20060909055503.96452.qmail@web8614.mail.in.yahoo.com>
Message-ID: <9EFC04356BBC4745B67A41B106F4A47A01BCDE67@TPN-EX01.PROJECT-NETWORK.COM>
Suresh,
It sounds like for some reason you are creating image objects all the time and they are not being garbage collected. Truth be told, browsers are not really designed to do this sort of thing, so even if your code is theoretically correct, you might have to ?help it along? a bit to get the browser to behave properly.
I would suggest that you use one image and cycle its src attribute instead.
To do the preload, again use one image object which is not actually displayed and cycle its src until all are in the cache. The browser cache is at the url level not the object level, so there is no requirement to store image objects for the data they contain to be cached.
Hope it helps.
AJ
Alexander J Turner Ph.D.
HYPERLINK "http://www.deployview.com"www.deployview.com
HYPERLINK "http://www.nerds-central.blogspot.com"www.nerds-central.blogspot.com
HYPERLINK "http://www.project-network.com"www.project-network.com
_____
From: javascript-bounces at LaTech.edu [mailto:javascript-bounces at LaTech.edu] On Behalf Of suresh kumar
Sent: 09 September 2006 06:55
To: javascript at latech.edu
Subject: [Javascript] virual memory proeblem
Hi,
I am facing one problem in my project.i am working in myadtv project that will display ads one by one in big LCD screen .
suppose if i want display 100 ads one by one for a particular duration,after displaying the 100 th ad again it will start from 1 ad and goes in a loop until the user closes the browser.
my problem is ,if its runs for continuously more than 10 hours if am displaying the message as
" your system virtual memory is too low,windows is increasing the size of the virtual memory paging file ,during this process memory request for some application may be denied". i can't understand this error message ,can any one tell me what this errror message.
the logc behind our code - we are using javascript "imagepreloader() function to load the ads in the browser cache once it gets loaded then it will start displaying one by one.
_____
Find out what India is talking about on - HYPERLINK "http://us.rd.yahoo.com/mail/in/yanswers/*http:/in.answers.yahoo.com/"Yahoo! Answers India
Send FREE SMS to your friend's mobile from Yahoo! Messenger Version 8. HYPERLINK "http://us.rd.yahoo.com/mail/in/messengertagline/*http:/in.messenger.yahoo.com"Get it NOW
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.2/442 - Release Date: 08/09/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.405 / Virus Database: 268.12.2/442 - Release Date: 08/09/2006
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
From asureshkumar_1983 at yahoo.co.in Sat Sep 9 06:03:35 2006
From: asureshkumar_1983 at yahoo.co.in (suresh kumar)
Date: Sat, 9 Sep 2006 12:03:35 +0100 (BST)
Subject: [Javascript] virual memory proeblem
In-Reply-To: <9EFC04356BBC4745B67A41B106F4A47A01BCDE67@TPN-EX01.PROJECT-NETWORK.COM>
Message-ID: <20060909110335.27240.qmail@web8608.mail.in.yahoo.com>
Hi,
thxs for reply,but we are not only displaying only the image ad ,we are displaying image ad using object,flash and movie ad using