From trojani2000 at hotmail.com Sat Feb 7 18:11:58 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Sun, 8 Feb 2009 00:11:58 +0000 Subject: [Javascript] Dirty Button In-Reply-To: References: Message-ID: Hi Tedd, sorry for checking in this late. I think that in this particular casse, it would be better to "Reset the Value of the Result Field" in your page instead. This way - I believe - the client will have a clear view of what's going on with his actions and will never confuse old result(s) with his current selection(s). Regards. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Sun, 25 Jan 2009 12:55:17 -0500> To: javascript at lists.evolt.org> From: tedd at sperling.com> Subject: [Javascript] Dirty Button> > Hi gang:> > I had a problem and solved it -- here's the write-up:> > http://www.webbytedd.com/b/update-select/index.php> > What do you think of the solution?> > Cheers,> > tedd> > -- > -------> http://sperling.com http://ancientstones.com http://earthstones.com> _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live?: Keep your life in sync. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_t1_allup_explore_022009 From vkocher at wombat.ch Tue Feb 10 15:29:21 2009 From: vkocher at wombat.ch (vkocher at wombat.ch) Date: Tue, 10 Feb 2009 22:29:21 +0100 Subject: [Javascript] variable DIV In-Reply-To: References: Message-ID: <4991F1B1.7060601@wombat.ch> Hello i have a page with 3 column the Middle and right one have a fixed width the Left one has a Variable Width, as large as the Browser/Screen would be. It is possible to read it out with javascript how large the Screen/Browser is deduct the px from the Middle and right Column and add the Result to a DIV Structure? and how to do it? the place this should work would be http://jetztunterwegs.blogspot.com/ and sorry i am a beginner withe javascript - so the how to do should be easy to add to my page thanks a lot have a nice day vincent From trojani2000 at hotmail.com Tue Feb 10 17:14:46 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Tue, 10 Feb 2009 23:14:46 +0000 Subject: [Javascript] variable DIV In-Reply-To: <4991F1B1.7060601@wombat.ch> References: <4991F1B1.7060601@wombat.ch> Message-ID: Hi Kocher, -yes, it is possible... But I Am not that sure I understand your final goal. Can you please first explain to us: what would you like to do with with that value? Since your explanation: > and add the Result to a DIV Structure?" is not very explanatory. What do you mean with: and add the Result to a DIV Structure? Regards.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Tue, 10 Feb 2009 22:29:21 +0100> From: vkocher at wombat.ch> To: javascript at lists.evolt.org> Subject: [Javascript] variable DIV> > Hello> i have a page with 3 column the Middle and right one have a fixed > width the Left one has a Variable Width, as large as the Browser/Screen > would be.> > It is possible to read it out with javascript how large the > Screen/Browser is deduct the px from the Middle and right Column and add > the Result to a DIV Structure?> > and how to do it?> the place this should work would be http://jetztunterwegs.blogspot.com/> and sorry i am a beginner withe javascript - so the how to do should be > easy to add to my page> > thanks a lot> have a nice day> > vincent> _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live?: E-mail. Chat. Share. Get more ways to connect. http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009 From vkocher at wombat.ch Tue Feb 10 23:49:44 2009 From: vkocher at wombat.ch (vkocher at wombat.ch) Date: Wed, 11 Feb 2009 06:49:44 +0100 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> Message-ID: <499266F8.9040701@wombat.ch> Hello and thanks for the feedback, so my blog has 3 column at this time this is definition of the DIV code for the Leftside (MAP Side) #left-sidebar-wrapper (line 146) { margin-left: 14px; width: 50%; float: left; background-color: #ffffff; display: inline; overflow-x: hidden; overflow-y: hidden; } I would imagine a sript checking out the size of the browser deduct 600px (600px = the middle and right column) keep the result in a variable to add it like this width: Variable; in this case it would not be anymore important about the sice of the screen - some will have a samll map othe a large map! and yes the MAP itself resize allready outmatic to the right size have a nice day vincent Troy III Ajnej wrote: > Hi Kocher, > -yes, it is possible... > But I Am not that sure I understand your final goal. > Can you please first explain to us: what would you like to do with > with that value? Since your explanation: > >> and add the Result to a DIV Structure?" >> > is not very explanatory. > What do you mean with: and add the Result to a DIV Structure? > > Regards.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Tue, 10 Feb 2009 22:29:21 +0100> From: vkocher at wombat.ch> To: javascript at lists.evolt.org> Subject: [Javascript] variable DIV> > Hello> i have a page with 3 column the Middle and right one have a fixed > width the Left one has a Variable Width, as large as the Browser/Screen > would be.> > It is possible to read it out with javascript how large the > Screen/Browser is deduct the px from the Middle and right Column and add > the Result to a DIV Structure?> > and how to do it?> the place this should work would be http://jetztunterwegs.blogspot.com/> and sorry i am a beginner withe javascript - so the how to do should be > easy to add to my page> > thanks a lot> have a nice day> > vincent> _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript > _________________________________________________________________ > Windows Live?: E-mail. Chat. Share. Get more ways to connect. > http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009 > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > > > > > From tedd at sperling.com Wed Feb 11 09:33:44 2009 From: tedd at sperling.com (tedd) Date: Wed, 11 Feb 2009 10:33:44 -0500 Subject: [Javascript] variable DIV In-Reply-To: <499266F8.9040701@wombat.ch> References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> Message-ID: At 6:49 AM +0100 2/11/09, vkocher at wombat.ch wrote: >I would imagine a sript checking out the size of the browser deduct >600px (600px = the middle and right column) keep the result in a variable >to add it like this > >width: Variable; You can have a variable in css IF you encapsulate it in php -- I describe it here: http://sperling.com/examples/pcss/ HTH's tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com From rick at niof.net Wed Feb 11 10:01:30 2009 From: rick at niof.net (Rick Pasotto) Date: Wed, 11 Feb 2009 11:01:30 -0500 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> Message-ID: <20090211160130.GQ22176@niof.net> On Wed, Feb 11, 2009 at 10:33:44AM -0500, tedd wrote: > > You can have a variable in css IF you encapsulate it in php -- I > describe it here: > > http://sperling.com/examples/pcss/ Your example doesn't work because '#content h2' has a greater specificity than 'h2' so even though 'h2' is defined later, '#content h2' takes precedence. -- "Advice is like snow - the softer it falls, the longer it dwells upon, and the deeper it sinks into the mind." -- Samuel Taylor Coleridge Rick Pasotto rick at niof.net http://www.niof.net From trojani2000 at hotmail.com Thu Feb 12 01:16:23 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Thu, 12 Feb 2009 07:16:23 +0000 Subject: [Javascript] variable DIV In-Reply-To: <499266F8.9040701@wombat.ch> References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> Message-ID: Hi there... I think I finally understand your problem :) Check these lines of your css first: > margin-left: 14px; > width: 50%; /*remove this line! */ > float: left; > background-color: #ffffff; > display: inline;/*(?) not needed*/ > /*merge the following to: overflow: hidden;*/ > overflow-x: hidden; > overflow-y: hidden; and try this: ----------------------------- 8< ------------------------------- var container = document.getElementById('[idName1]');// [idName1] - replace with the ID of your 3 column wrapper! var colls = [numValue];/* [numValue] - replace with the value of your fixed columns * total width! exmp.: 600, or give it some air: 612. */ var leftcol = document.getElementById('[idName2]');// [idName2] - replace with the ID of your varWidth column! function adjustVarWidthCol(){ var width = (container.offsetWidth - colls); leftcol.style.width = width + 'px'; } adjustVarWidthCol(); onresize = adjustVarWidthCol; ----------------------------- 8< ------------------------------- * place this script before the end of Date: Wed, 11 Feb 2009 06:49:44 +0100> From: vkocher at wombat.ch> To: javascript at lists.evolt.org> Subject: Re: [Javascript] variable DIV> > Hello> and thanks for the feedback,> so my blog has 3 column> > at this time this is definition of the DIV code for the Leftside (MAP Side)> > #left-sidebar-wrapper (line 146)> {> margin-left: 14px;> width: 50%;> float: left;> background-color: #ffffff;> display: inline;> overflow-x: hidden;> overflow-y: hidden;> }> > I would imagine a sript checking out the size of the browser deduct > 600px (600px = the middle and right column) keep the result in a variable> to add it like this> > width: Variable;> > in this case it would not be anymore important about the sice of the > screen - some will have a samll map othe a large map!> and yes the MAP itself resize allready outmatic to the right size> > have a nice day> vincent> > > > Troy III Ajnej wrote:> > Hi Kocher,> > -yes, it is possible...> > But I Am not that sure I understand your final goal.> > Can you please first explain to us: what would you like to do with> > with that value? Since your explanation:> > > >> and add the Result to a DIV Structure?" > >> > > is not very explanatory.> > What do you mean with: and add the Result to a DIV Structure? > > > > Regards.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Tue, 10 Feb 2009 22:29:21 +0100> From: vkocher at wombat.ch> To: javascript at lists.evolt.org> Subject: [Javascript] variable DIV> > Hello> i have a page with 3 column the Middle and right one have a fixed > width the Left one has a Variable Width, as large as the Browser/Screen > would be.> > It is possible to read it out with javascript how large the > Screen/Browser is deduct the px from the Middle and right Column and add > the Result to a DIV Structure?> > and how to do it?> the place this should work would be http://jetztunterwegs.blogspot.com/> and sorry i am a beginner withe javascript - so the how to do should be > easy to add to my page> > thanks a lot> have a nice day> > vincent> _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript> > _________________________________________________________________> > Windows Live?: E-mail. Chat. Share. Get more ways to connect. > > http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009> > _______________________________________________> > Javascript mailing list> > Javascript at lists.evolt.org> > http://lists.evolt.org/mailman/listinfo/javascript> >> >> >> >> > > > _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live?: E-mail. Chat. Share. Get more ways to connect. http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009 From tedd at sperling.com Thu Feb 12 07:10:45 2009 From: tedd at sperling.com (tedd) Date: Thu, 12 Feb 2009 08:10:45 -0500 Subject: [Javascript] variable DIV In-Reply-To: <20090211160130.GQ22176@niof.net> References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> Message-ID: At 11:01 AM -0500 2/11/09, Rick Pasotto wrote: >On Wed, Feb 11, 2009 at 10:33:44AM -0500, tedd wrote: >> >> You can have a variable in css IF you encapsulate it in php -- I >> describe it here: >> >> http://sperling.com/examples/pcss/ > >Your example doesn't work because '#content h2' has a greater >specificity than 'h2' so even though 'h2' is defined later, '#content h2' >takes precedence. My example is how to use a variable in css AND that does work. If you don't know how to use the technique, then that's a different matter. In short, don't blame the technique because you can't program. tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com From david at dorward.me.uk Thu Feb 12 08:20:48 2009 From: david at dorward.me.uk (David Dorward) Date: Thu, 12 Feb 2009 14:20:48 +0000 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> Message-ID: <49943040.9050203@dorward.me.uk> tedd wrote: > My example is how to use a variable in css AND that does work. Shame it is utterly useless for the use case - which involves inserting data that isn't directly available to PHP. -- David Dorward http://dorward.me.uk/ From scott at randomchaos.com Thu Feb 12 08:23:42 2009 From: scott at randomchaos.com (Scott Reynen) Date: Thu, 12 Feb 2009 07:23:42 -0700 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> Message-ID: <185DC676-C85D-4F66-B2AE-F62E4A8B5762@randomchaos.com> On [Feb 12], at [ Feb 12] 6:10 , tedd wrote: > At 11:01 AM -0500 2/11/09, Rick Pasotto wrote: >> On Wed, Feb 11, 2009 at 10:33:44AM -0500, tedd wrote: >>> >>> You can have a variable in css IF you encapsulate it in php -- I >>> describe it here: >>> >>> http://sperling.com/examples/pcss/ >> >> Your example doesn't work because '#content h2' has a greater >> specificity than 'h2' so even though 'h2' is defined later, >> '#content h2' >> takes precedence. > > My example is how to use a variable in css AND that does work. > > If you don't know how to use the technique, then that's a different > matter. In short, don't blame the technique because you can't program. For lack of an active administrator, I'll go ahead and point out that this is inappropriate. The original poster asked for advice on manipulating styles *based on the window size*. Window size only exists client-side, so PHP doesn't help there. And even if it did, this is a *JavaScript-specific* list. If you don't have anything to say about JavaScript, please take it off- list. And even if you do have something to say about JavaScript, if you can't say it without resorting to personal insults, please take that off-list as well. Peace, Scott From tedd at sperling.com Thu Feb 12 11:16:44 2009 From: tedd at sperling.com (tedd) Date: Thu, 12 Feb 2009 12:16:44 -0500 Subject: [Javascript] variable DIV In-Reply-To: <49943040.9050203@dorward.me.uk> References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> <49943040.9050203@dorward.me.uk> Message-ID: At 2:20 PM +0000 2/12/09, David Dorward wrote: >tedd wrote: >> My example is how to use a variable in css AND that does work. >Shame it is utterly useless for the use case - which involves inserting >data that isn't directly available to PHP. > >-- >David Dorward David: That very well may be, but I was addressing the question of a variable within css. That CAN be done as my examples demonstrates. As for the specific problem the OP wanted solved, I have no idea -- other than if the div is supposed to adjust to the screen size of the user, then php won't do it. That should be done client-side -- as such the OP should look to DOM scripting. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com From tedd at sperling.com Thu Feb 12 14:02:36 2009 From: tedd at sperling.com (tedd) Date: Thu, 12 Feb 2009 15:02:36 -0500 Subject: [Javascript] variable DIV In-Reply-To: <185DC676-C85D-4F66-B2AE-F62E4A8B5762@randomchaos.com> References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> <185DC676-C85D-4F66-B2AE-F62E4A8B5762@randomchaos.com> Message-ID: At 7:23 AM -0700 2/12/09, Scott Reynen wrote: >On [Feb 12], at [ Feb 12] 6:10 , tedd wrote: > >> At 11:01 AM -0500 2/11/09, Rick Pasotto wrote: >>> On Wed, Feb 11, 2009 at 10:33:44AM -0500, tedd wrote: >>>> >>>> You can have a variable in css IF you encapsulate it in php -- I >>>> describe it here: >>>> >>>> http://sperling.com/examples/pcss/ >>> >>> Your example doesn't work because '#content h2' has a greater >>> specificity than 'h2' so even though 'h2' is defined later, >>> '#content h2' >>> takes precedence. >> >> My example is how to use a variable in css AND that does work. >> >> If you don't know how to use the technique, then that's a different >> matter. In short, don't blame the technique because you can't program. > >For lack of an active administrator, I'll go ahead and point out that >this is inappropriate. > >The original poster asked for advice on manipulating styles *based on >the window size*. Window size only exists client-side, so PHP doesn't >help there. And even if it did, this is a *JavaScript-specific* list. >If you don't have anything to say about JavaScript, please take it off- >list. > >And even if you do have something to say about JavaScript, if you >can't say it without resorting to personal insults, please take that >off-list as well. > >Peace, >Scott Scott: While I can appreciate your need to comment, there was no insult. What I posted was a way to use variables from within css -- that is a fact and it works. What was posted in return to my post was "It don't work", which was not true. If the person did not know how to use the technique, that's fine. But their statement does provide sufficient proof that they did not know how to program in that instance. Stating fact, should not be construed as an insult. Furthermore, the OP asked for help with css, which is not javascript. One could conclude from your post that this entire thread should have never been made on this list. Is that what you are suggesting -- that we never help anyone who comes to this list with anything other than pure javascript? I mix server-side and client-side languages together all the time. I don't see much of a difference if you're trying to get a web application to work -- no language does it all and javascript does not live in a vacuum. I've had this same conversation with the pure css elite as well on their moderated list. Look, the OP asked a question and I took my time to answer as best as I could with a technique that does work. His reply was not only thankless, but he criticized a technique that works -- it's obvious to me that he had no idea of what it was or how to use it. Now, maybe that's Okay by you to allow a poster to: a) post something that is not true; b) and go away with a mistaken idea of what was being offered as a solution. But to me, the meaning of "help" does not mean that you give-in to the OP's mistaken ideas, but rather correct them. If you think I am still wrong, then please ignore anything I post. I have better things to do than argue that stating the truth is an insult. As Will Rogers once said "We're all ignorant, only in different subjects." Being ignorant is not an insult, it's just a statement of fact and we all can be described by it. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com From riegel at clearimageonline.com Thu Feb 12 14:57:50 2009 From: riegel at clearimageonline.com (Terry Riegel) Date: Thu, 12 Feb 2009 15:57:50 -0500 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> <49943040.9050203@dorward.me.uk> Message-ID: <18FAC118-E9FD-4C8C-A0E0-A39496C055AE@clearimageonline.com> On Feb 12, 2009, at 12:16 PM, tedd wrote: > >> > As for the specific problem the OP wanted solved, I have no idea -- > other than if the div is supposed to adjust to the screen size of the > user, then php won't do it. That should be done client-side -- as > such the OP should look to DOM scripting. Tedd, Seems to me he did ask for a client side solution, you offered a server side solution and then you seem troubled that he pointed out that your solution would not work/apply. > From rick at niof.net Thu Feb 12 16:09:18 2009 From: rick at niof.net (Rick Pasotto) Date: Thu, 12 Feb 2009 17:09:18 -0500 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> <185DC676-C85D-4F66-B2AE-F62E4A8B5762@randomchaos.com> Message-ID: <20090212220918.GD22176@niof.net> On Thu, Feb 12, 2009 at 03:02:36PM -0500, tedd wrote: > At 7:23 AM -0700 2/12/09, Scott Reynen wrote: > >On [Feb 12], at [ Feb 12] 6:10 , tedd wrote: > > > >> At 11:01 AM -0500 2/11/09, Rick Pasotto wrote: > >>> On Wed, Feb 11, 2009 at 10:33:44AM -0500, tedd wrote: > >>>> > >>>> You can have a variable in css IF you encapsulate it in php -- I > >>>> describe it here: > >>>> > >>>> http://sperling.com/examples/pcss/ > >>> > >>> Your example doesn't work because '#content h2' has a greater > >>> specificity than 'h2' so even though 'h2' is defined later, > >>> '#content h2' > >>> takes precedence. > >> > >> My example is how to use a variable in css AND that does work. > >> > >> If you don't know how to use the technique, then that's a different > >> matter. In short, don't blame the technique because you can't program. > > > >For lack of an active administrator, I'll go ahead and point out that > >this is inappropriate. > > > >The original poster asked for advice on manipulating styles *based on > >the window size*. Window size only exists client-side, so PHP doesn't > >help there. And even if it did, this is a *JavaScript-specific* list. > >If you don't have anything to say about JavaScript, please take it off- > >list. > > > >And even if you do have something to say about JavaScript, if you > >can't say it without resorting to personal insults, please take that > >off-list as well. > > > >Peace, > >Scott > > Scott: > > While I can appreciate your need to comment, there was no insult. Yes there was. > What I posted was a way to use variables from within css -- that is a > fact and it works. True, but irrelevant. You gave the url of a webpage using your technique. That webpage did NOT work as you intended. What you intended to display as green did NOT display as green for the reasons I gave. > What was posted in return to my post was "It don't work", which was not true. Your *example* (ie, webpage) doesn't work. You really should learn to read. > If the person did not know how to use the technique, that's fine. I said absolutely nothing about your technique. What I pointed out was that your resulting css did not do what you wanted it to do. > But their statement does provide sufficient proof that they did not > know how to program in that instance. Stating fact, should not be > construed as an insult. What you stated was NOT a fact. It was very much in error. Careful reading would have prevented your error. -- "Moreover, any man more right than his neighbors constitutes a majority of one already." -- Henry David Thoreau Rick Pasotto rick at niof.net http://www.niof.net From tedd at sperling.com Fri Feb 13 07:30:29 2009 From: tedd at sperling.com (tedd) Date: Fri, 13 Feb 2009 08:30:29 -0500 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <20090211160130.GQ22176@niof.net> <185DC676-C85D-4F66-B2AE-F62E4A8B5762@randomchaos.com> <30863128.1234468991001.JavaMail.root@m01> Message-ID: To all: Considering that Paul Novitski pointed out the errors of my ways privately, I would like to apologize. My reply was not defending myself but rather the technique. The technique does provide variables in css, and that was my point. But, it does so for server-side and not for client-side applications as the OP wanted. So, Paul et al was right. Apologies to all. I should not have posted as I did. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com From davidh126 at writeme.com Fri Feb 13 12:17:29 2009 From: davidh126 at writeme.com (David Hucklesby) Date: Fri, 13 Feb 2009 10:17:29 -0800 Subject: [Javascript] variable DIV In-Reply-To: <20090212220918.GD22176@niof.net> Message-ID: <2009213101729.470385@david-7cda2c387> On Thu, 12 Feb 2009 17:09:18 -0500, Rick Pasotto wrote: > On Thu, Feb 12, 2009 at 03:02:36PM -0500, tedd wrote: >> At 7:23 AM -0700 2/12/09, Scott Reynen wrote: >>> On [Feb 12], at [ Feb 12] 6:10 , tedd wrote: >>> blah, blah, blah. Calm down, folks. All anyone here is doing is trying to help. I, for one, really appreciate that - "appropriate" or not. FWIW there are proposals for variables in CSS out there, e.g. - ... but I don't know what would be exposed to the DOM, Cordially, David -- From hassan at webtuitive.com Fri Feb 13 12:40:22 2009 From: hassan at webtuitive.com (Hassan Schroeder) Date: Fri, 13 Feb 2009 10:40:22 -0800 Subject: [Javascript] variable DIV In-Reply-To: <2009213101729.470385@david-7cda2c387> References: <2009213101729.470385@david-7cda2c387> Message-ID: <4995BE96.9040109@webtuitive.com> David Hucklesby wrote: > FWIW there are proposals for variables in CSS out there, e.g. - > > And so everything old is new again: since Netscape's original style mechanism, JavaScript Style Sheets (JSSS), offered exactly that :-) -- Hassan Schroeder ----------------------------- hassan at webtuitive.com Webtuitive Design === (+1) 408-621-3445 === http://webtuitive.com dream. code. From lester at denhaag.org Fri Feb 13 14:42:03 2009 From: lester at denhaag.org (J. Lester Novros II) Date: Fri, 13 Feb 2009 21:42:03 +0100 Subject: [Javascript] variable DIV In-Reply-To: <4995BE96.9040109@webtuitive.com> References: <2009213101729.470385@david-7cda2c387> <4995BE96.9040109@webtuitive.com> Message-ID: <4995DB1B.90708@denhaag.org> Hassan Schroeder wrote: > And so everything old is new again: since Netscape's original style > mechanism, JavaScript Style Sheets (JSSS), offered exactly that :-) Wow... You must be running with the JavaScript/Netscape herd as long as me [or possibly even longer] that you should even remember this... Something along the lines of [styleDef]: &; Right..? Great idea that, and more or less standards compliant as well, considering the ampersand-semicolon notation. I'd love to have that now. l8R lES -- Microsoft's business practices have fundamentally diminished (in fact, came very close to eliminating) competition, choice and innovation in how people access the Internet. Mitchell Baker - Mozilla Chair http://www.supermarionation.tv From vkocher at wombat.ch Sun Feb 15 03:19:46 2009 From: vkocher at wombat.ch (vkocher at wombat.ch) Date: Sun, 15 Feb 2009 10:19:46 +0100 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> Message-ID: <4997DE32.2070807@wombat.ch> @Hello Troy i have triey this way but it is not working - but maybe i have done something wrong. i have the change over there http://testgooglemap.blogspot.com/ i think a problem is [idName1] should be the wrapper around the other 3 Column but I think i don't have a wrapper around and i am right i have to add this script and mark it as thanks for all the feedback and keep peacefull vincent Troy III Ajnej wrote: > Hi there... > I think I finally understand your problem :) > Check these lines of your css first: > > > margin-left: 14px; > width: 50%; /*remove this line! */ > float: left; > background-color: #ffffff; > display: inline;/*(?) not needed*/ > > /*merge the following to: overflow: hidden;*/ > overflow-x: hidden; > overflow-y: hidden; > > and try this: > > ----------------------------- 8< ------------------------------- > > var container = document.getElementById('[idName1]');// [idName1] - replace with the ID of your 3 column wrapper! > > var colls = [numValue];/* [numValue] - replace with the value of your fixed columns > * total width! exmp.: 600, or give it some air: 612. */ > var leftcol = document.getElementById('[idName2]');// [idName2] - replace with the ID of your varWidth column! > > > function adjustVarWidthCol(){ var width = (container.offsetWidth - colls); leftcol.style.width = width + 'px'; } > adjustVarWidthCol(); onresize = adjustVarWidthCol; > ----------------------------- 8< ------------------------------- > * place this script before the end of > Not very readable I guess, but it will do. You will probably need to > adjust the colls var value untill you get the right size..., and don't > forget the script/script tags :D > > Regards.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Wed, 11 Feb 2009 06:49:44 +0100> From: vkocher at wombat.ch> To: javascript at lists.evolt.org> Subject: Re: [Javascript] variable DIV> > Hello> and thanks for the feedback,> so my blog has 3 column> > at this time this is definition of the DIV code for the Leftside (MAP Side)> > #left-sidebar-wrapper (line 146)> {> margin-left: 14px;> width: 50%;> float: left;> background-color: #ffffff;> display: inline;> overflow-x: hidden;> overflow-y: hidden;> }> > I would imagine a sript checking out the size of the browser deduct > 600px (600px = the middle and right column) keep the result in a variable> to add it like this> > width: Variable;> > in this case it would not be anymore important about the sice of the > screen - some will have a samll map othe a large map!> and yes the MAP itself resize allready outmatic to the right size> > have a nice day> vincent> > > > Troy III Ajnej wrote:> > Hi Kocher,> > -yes, it is possible...> > But I Am not that sure I understand your final goal.> > Can you please first explain to us: what would you like to do with> > with that value? Since your explanation:> > > >> and add the Result to a DIV Structure?" > >> > > is not very explanatory.> > What do you mean with: and add the Result to a DIV Structure? > > > > Regards.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Tue, 10 Feb 2009 22:29:21 +0100> From: vkocher at wombat.ch> To: javascript at lists.evolt.org> Subject: [Javascript] variable DIV> > Hello> i have a page with 3 column the Middle and right one have a fixed > width the Left one has a Variable Width, as large as the Browser/Screen > would be.> > It is possible to read it out with javascript how large the > Screen/Browser is deduct the px from the Middle and right Column and add > the Result to a DIV Structure?> > and how to do it?> the place this should work would be http://jetztunterwegs.blogspot.com/> and sorry i am a beginner withe javascript - so the how to do should be > easy to add to my page> > thanks a lot> have a nice day> > vincent> _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript> > _________________________________________________________________> > Windows Live?: E-mail. Chat. Share. Get more ways to connect. > > http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009> > _______________________________________________> > Javascript mailing list> > Javascript at lists.evolt.org> > http://lists.evolt.org/mailman/listinfo/javascript> >> >> >> >> > > > _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript > _________________________________________________________________ > Windows Live?: E-mail. Chat. Share. Get more ways to connect. > http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009 > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > > > > > From trojani2000 at hotmail.com Mon Feb 16 00:09:06 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Mon, 16 Feb 2009 06:09:06 +0000 Subject: [Javascript] variable DIV In-Reply-To: <4997DE32.2070807@wombat.ch> References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <4997DE32.2070807@wombat.ch> Message-ID: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Sun, 15 Feb 2009 10:19:46 +0100 > From: vkocher at wombat.ch > To: javascript at lists.evolt.org > Subject: Re: [Javascript] variable DIV > > @Hello Troy > i have triey this way > but it is not working - but maybe i have done something wrong. > i have the change over there http://testgooglemap.blogspot.com/ > > i think a problem is [idName1] should be the wrapper around the other 3 > Column but I think i don't have a wrapper around > > and i am right i have to add this script and mark it as > > thanks for all the feedback and keep peacefull > > vincent _________________________________________________________________ Windows Live?: E-mail. Chat. Share. Get more ways to connect. http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009 From vkocher at wombat.ch Mon Feb 16 03:21:24 2009 From: vkocher at wombat.ch (vkocher at wombat.ch) Date: Mon, 16 Feb 2009 10:21:24 +0100 Subject: [Javascript] variable DIV In-Reply-To: References: <4991F1B1.7060601@wombat.ch> <499266F8.9040701@wombat.ch> <4997DE32.2070807@wombat.ch> Message-ID: <49993014.5060402@wombat.ch> @Troy III Ajnej YES! It works perfect. Thanks a lot it is basicly also to find out the hight not only the Width? ;-) vincent Troy III Ajnej wrote: > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Troy III > progressive art enterprise > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > >> Date: Sun, 15 Feb 2009 10:19:46 +0100 >> From: vkocher at wombat.ch >> To: javascript at lists.evolt.org >> Subject: Re: [Javascript] variable DIV >> >> @Hello Troy >> i have triey this way >> but it is not working - but maybe i have done something wrong. >> i have the change over there http://testgooglemap.blogspot.com/ >> >> i think a problem is [idName1] should be the wrapper around the other 3 >> Column but I think i don't have a wrapper around >> >> and i am right i have to add this script and mark it as >> >> thanks for all the feedback and keep peacefull >> >> vincent >> > > _________________________________________________________________ > Windows Live?: E-mail. Chat. Share. Get more ways to connect. > http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_allup_howitworks_022009 > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > > > > > From Dstoltz at SHH.ORG Mon Feb 16 07:14:29 2009 From: Dstoltz at SHH.ORG (David Stoltz) Date: Mon, 16 Feb 2009 08:14:29 -0500 Subject: [Javascript] Checking Radio Boxes with a loop Message-ID: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> Hi all, I have 33 questions on a form, each with YES/NO possibilities. I'm trying to add a button to "check all" yeses - Here's my code: I know this is not the right way to do this, and of course it doesn't work....is there some easy way to dynamically say "question1", then "question2", etc? If I replace the (i) with a number, it works of course, and this is the part I'm having trouble with. I didn't want to do this: form1.question1[0].checked=true; form1.question2[0].checked=true; form1.question3[0].checked=true; etc.... Any help? Thanks! From bader at tcbader.com Mon Feb 16 07:26:26 2009 From: bader at tcbader.com (Terry Bader) Date: Mon, 16 Feb 2009 06:26:26 -0700 Subject: [Javascript] SPAM-LOW: Checking Radio Boxes with a loop Message-ID: <2c789891$21b9bb1b$5d209b51$@com> try eval ("form1.question" + i +".checked=true") could avoid the eval statement by putting all the questions in the same group using the name attribute then for (i = 0; i < document.myform.list.length; i++) document.myform.list[i].checked = true ; can be used ~Terry ---------------------------------------- From: "David Stoltz" Sent: Monday, February 16, 2009 8:17 AM To: javascript at lists.evolt.org Subject: SPAM-LOW: [Javascript] Checking Radio Boxes with a loop Hi all, I have 33 questions on a form, each with YES/NO possibilities. I'm trying to add a button to "check all" yeses - Here's my code: I know this is not the right way to do this, and of course it doesn't work....is there some easy way to dynamically say "question1", then "question2", etc? If I replace the (i) with a number, it works of course, and this is the part I'm having trouble with. I didn't want to do this: form1.question1[0].checked=true; form1.question2[0].checked=true; form1.question3[0].checked=true; etc.... Any help? Thanks! _______________________________________________ Javascript mailing list Javascript at lists.evolt.org http://lists.evolt.org/mailman/listinfo/javascript From david at dorward.me.uk Mon Feb 16 08:04:26 2009 From: david at dorward.me.uk (David Dorward) Date: Mon, 16 Feb 2009 14:04:26 +0000 Subject: [Javascript] Checking Radio Boxes with a loop In-Reply-To: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> References: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> Message-ID: <4999726A.1010007@dorward.me.uk> David Stoltz wrote: > I didn't want to do this: > > form1.question1[0].checked=true; > form1.question2[0].checked=true; > form1.question3[0].checked=true; > etc.... This should do the trick: var iterator = 1; while (var radio_group = form1.elements["question" + iterator]) { radio_group[0].checked = true; iterator++; } -- David Dorward From nick at nickfitz.co.uk Mon Feb 16 08:07:38 2009 From: nick at nickfitz.co.uk (Nick Fitzsimons) Date: Mon, 16 Feb 2009 14:07:38 -0000 (GMT) Subject: [Javascript] Checking Radio Boxes with a loop In-Reply-To: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> References: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> Message-ID: <53793.84.12.87.209.1234793258.squirrel@www.easilymail.co.uk> Hi, Try: for (i = 1; i < 33; i++) { form1['question' + i][0].checked = true; } (I haven't tested this, but it should work.) Regards, Nick. On Mon, February 16, 2009 1:14 pm, David Stoltz wrote: > Hi all, > > I have 33 questions on a form, each with YES/NO possibilities. I'm > trying to add a button to "check all" yeses - Here's my code: > > > > I know this is not the right way to do this, and of course it doesn't > work....is there some easy way to dynamically say "question1", then > "question2", etc? If I replace the (i) with a number, it works of > course, and this is the part I'm having trouble with. I didn't want to > do this: > > form1.question1[0].checked=true; > form1.question2[0].checked=true; > form1.question3[0].checked=true; > etc.... > > > > Any help? > Thanks! > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > -- Nick Fitzsimons http://www.nickfitz.co.uk/ From Dstoltz at SHH.ORG Mon Feb 16 09:29:38 2009 From: Dstoltz at SHH.ORG (David Stoltz) Date: Mon, 16 Feb 2009 10:29:38 -0500 Subject: [Javascript] Checking Radio Boxes with a loop In-Reply-To: <53793.84.12.87.209.1234793258.squirrel@www.easilymail.co.uk> References: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> <53793.84.12.87.209.1234793258.squirrel@www.easilymail.co.uk> Message-ID: <487E7D0857FE094590BF2DC33FE3E1080737C7EB@SHHS-MAIL.SHH.ORG> Thanks all! I see there are many solutions! This is the one I went with: for(i=1;i<34;i++) eval("form1.question" + i + "[0].checked=true"); Again, thanks for all the quick responses! -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Nick Fitzsimons Sent: Monday, February 16, 2009 9:08 AM To: JavaScript List Cc: javascript at lists.evolt.org Subject: Re: [Javascript] Checking Radio Boxes with a loop Hi, Try: for (i = 1; i < 33; i++) { form1['question' + i][0].checked = true; } (I haven't tested this, but it should work.) Regards, Nick. On Mon, February 16, 2009 1:14 pm, David Stoltz wrote: > Hi all, > > I have 33 questions on a form, each with YES/NO possibilities. I'm > trying to add a button to "check all" yeses - Here's my code: > > > > I know this is not the right way to do this, and of course it doesn't > work....is there some easy way to dynamically say "question1", then > "question2", etc? If I replace the (i) with a number, it works of > course, and this is the part I'm having trouble with. I didn't want to > do this: > > form1.question1[0].checked=true; > form1.question2[0].checked=true; > form1.question3[0].checked=true; > etc.... > > > > Any help? > Thanks! > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > -- Nick Fitzsimons http://www.nickfitz.co.uk/ _______________________________________________ Javascript mailing list Javascript at lists.evolt.org http://lists.evolt.org/mailman/listinfo/javascript From david at dorward.me.uk Mon Feb 16 09:36:24 2009 From: david at dorward.me.uk (David Dorward) Date: Mon, 16 Feb 2009 15:36:24 +0000 Subject: [Javascript] Checking Radio Boxes with a loop In-Reply-To: <487E7D0857FE094590BF2DC33FE3E1080737C7EB@SHHS-MAIL.SHH.ORG> References: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> <53793.84.12.87.209.1234793258.squirrel@www.easilymail.co.uk> <487E7D0857FE094590BF2DC33FE3E1080737C7EB@SHHS-MAIL.SHH.ORG> Message-ID: <499987F8.6070104@dorward.me.uk> David Stoltz wrote: > Thanks all! I see there are many solutions! This is the one I went with: > > for(i=1;i<34;i++) > eval("form1.question" + i + "[0].checked=true"); > > Again, thanks for all the quick responses! Don't use that one. http://www.javascripttoolbox.com/bestpractices/#eval -- David Dorward From nick at nickfitz.co.uk Mon Feb 16 10:47:10 2009 From: nick at nickfitz.co.uk (Nick Fitzsimons) Date: Mon, 16 Feb 2009 16:47:10 -0000 (GMT) Subject: [Javascript] Checking Radio Boxes with a loop In-Reply-To: <487E7D0857FE094590BF2DC33FE3E1080737C7EB@SHHS-MAIL.SHH.ORG> References: <487E7D0857FE094590BF2DC33FE3E1080737C7C9@SHHS-MAIL.SHH.ORG> <53793.84.12.87.209.1234793258.squirrel@www.easilymail.co.uk> <487E7D0857FE094590BF2DC33FE3E1080737C7EB@SHHS-MAIL.SHH.ORG> Message-ID: <54439.84.12.87.209.1234802830.squirrel@www.easilymail.co.uk> Hi, Unfortunately, that's actually the *worst* possible solution: eval() incurs a terrible performance penalty, as it has to create (and then throw away) a brand new instance of the script execution engine every time through the loop. It's generally agreed that "eval() is evil" [1] [2] although there are some exceptions to this rule. Your case isn't one of those exceptions. I would strongly suggest using the solution suggested by both David Dorward and myself :-) HTH, Nick. [1] and - Eric Lippert worked on the Microsoft JScript engine. [2] - Mike Shaver worked at Netscape and is now at Mozilla. On Mon, February 16, 2009 3:29 pm, David Stoltz wrote: > Thanks all! I see there are many solutions! This is the one I went with: > > for(i=1;i<34;i++) > eval("form1.question" + i + "[0].checked=true"); > > Again, thanks for all the quick responses! > > > -----Original Message----- > From: javascript-bounces at lists.evolt.org > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Nick Fitzsimons > Sent: Monday, February 16, 2009 9:08 AM > To: JavaScript List > Cc: javascript at lists.evolt.org > Subject: Re: [Javascript] Checking Radio Boxes with a loop > > Hi, > > Try: > > for (i = 1; i < 33; i++) { > form1['question' + i][0].checked = true; > } > > (I haven't tested this, but it should work.) > > Regards, > > Nick. > > On Mon, February 16, 2009 1:14 pm, David Stoltz wrote: >> Hi all, >> >> I have 33 questions on a form, each with YES/NO possibilities. I'm >> trying to add a button to "check all" yeses - Here's my code: >> >> >> >> I know this is not the right way to do this, and of course it doesn't >> work....is there some easy way to dynamically say "question1", then >> "question2", etc? If I replace the (i) with a number, it works of >> course, and this is the part I'm having trouble with. I didn't want to >> do this: >> >> form1.question1[0].checked=true; >> form1.question2[0].checked=true; >> form1.question3[0].checked=true; >> etc.... >> >> >> >> Any help? >> Thanks! >> _______________________________________________ >> Javascript mailing list >> Javascript at lists.evolt.org >> http://lists.evolt.org/mailman/listinfo/javascript >> > > > -- > Nick Fitzsimons > http://www.nickfitz.co.uk/ > > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > -- Nick Fitzsimons http://www.nickfitz.co.uk/ From dshaw256 at earthlink.net Tue Feb 17 08:01:13 2009 From: dshaw256 at earthlink.net (Dave Shaw) Date: Tue, 17 Feb 2009 09:01:13 -0500 Subject: [Javascript] Checking Radio Boxes with a loop In-Reply-To: References: Message-ID: <1234879273.3658.8.camel@localhost.localdomain> I see that you have several solutions. I just wanted to toss another one at you, as it's a little different from what you have already seen. I had a need to do the same thing, with a twist; I wanted to receive the check boxes as an array when they got back to my application. I have an identifier associated with each of as many as 50 check boxes, and all I cared about was collecting a list of identifiers. I defined the check boxes as follows (examples from a test stub I wrote to work this out; not from my production application):  First check box
 Second check box
 Third check box
 Fourth check box
PHP will see that, on entry, as an array named CB with values from only the checked boxes. Javascript on the page can iterate through the array as follows: function validate() { var count = 0; var length; length = document.testform["cb[]"].length; for (i=0; i > -------- Forwarded Message -------- > > From: David Stoltz > > Reply-To: JavaScript List > > To: javascript at lists.evolt.org > > Subject: [Javascript] Checking Radio Boxes with a loop > > Date: Mon, 16 Feb 2009 08:14:29 -0500 > > > > > > Hi all, > > > > I have 33 questions on a form, each with YES/NO possibilities. I'm > > trying to add a button to "check all" yeses - Here's my code: > > > > > > > > I know this is not the right way to do this, and of course it doesn't > > work....is there some easy way to dynamically say "question1", then > > "question2", etc? If I replace the (i) with a number, it works of > > course, and this is the part I'm having trouble with. I didn't want to > > do this: > > > > form1.question1[0].checked=true; > > form1.question2[0].checked=true; > > form1.question3[0].checked=true; > > etc.... > > > > > > > > Any help? > > Thanks! > > > > e From riegel at clearimageonline.com Wed Feb 18 13:03:09 2009 From: riegel at clearimageonline.com (Terry Riegel) Date: Wed, 18 Feb 2009 14:03:09 -0500 Subject: [Javascript] Unobtrusive onsubmit Message-ID: I am working through an unobtrusive bit of javascript and wonder if anyone might be able to lend a hand.
I would like to take this onSubmit out of the form declaration and put it in an startup function that runs on load. So I have this... document.getElementById('testform').onsubmit=TestDataCheck; I am not sure of the syntax that would duplicate the return part of the obtrusive JS. I have tried this... document.getElementById('testform').onsubmit=return TestDataCheck; How would I get it to invalidate the action of the form and just do something else? Any help will be greatly appreciated. Terry Riegel From lester at denhaag.org Wed Feb 18 13:24:33 2009 From: lester at denhaag.org (J. Lester Novros II) Date: Wed, 18 Feb 2009 20:24:33 +0100 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: References: Message-ID: <499C6071.8080207@denhaag.org> Terry, Terry Riegel wrote: > So I have this... > document.getElementById('testform').onsubmit=TestDataCheck; Not quite to the point but be aware that IE does not differ between 'name' and 'id' namespaces so this will have consequences for your script. Just a heads up. l8R lES -- Microsoft's business practices have fundamentally diminished (in fact, came very close to eliminating) competition, choice and innovation in how people access the Internet. Mitchell Baker - Mozilla Chair http://www.supermarionation.tv From peter at brunone.com Wed Feb 18 13:32:04 2009 From: peter at brunone.com (Peter Brunone) Date: Wed, 18 Feb 2009 12:32:04 -0700 Subject: [Javascript] Unobtrusive onsubmit Message-ID: <4231e17d$7887d231$2fc5ab8f$@com> > IE does not differ between 'name' > and 'id' namespaces What exactly does that mean? ---------------------------------------- From: "J. Lester Novros II" Terry, Terry Riegel wrote: > So I have this... > document.getElementById('testform').onsubmit=TestDataCheck; Not quite to the point but be aware that IE does not differ between 'name' and 'id' namespaces so this will have consequences for your script. Just a heads up. l8R lES From lester at denhaag.org Wed Feb 18 13:43:31 2009 From: lester at denhaag.org (J. Lester Novros II) Date: Wed, 18 Feb 2009 20:43:31 +0100 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: <4231e17d$7887d231$2fc5ab8f$@com> References: <4231e17d$7887d231$2fc5ab8f$@com> Message-ID: <499C64E3.2070906@denhaag.org> Peter Brunone wrote: >> IE does not differ between 'name' >> and 'id' namespaces > > What exactly does that mean? It means that IE will *always* return the element with the corresponding name rather than the element with the desired id if there are two elements, one with an 'id' and another with a 'name' that are identical. I don't really know what happens when one element has an identical id and name but I thought to better bring this up than have the script author get mired in difficult to trace bugs/unwanted script behaviour. Also, this came up on the list quite a while ago. Maybe the archives can be searched for the 'namespace' search term. l8R lES -- Microsoft's business practices have fundamentally diminished (in fact, came very close to eliminating) competition, choice and innovation in how people access the Internet. Mitchell Baker - Mozilla Chair http://www.supermarionation.tv From riegel at clearimageonline.com Wed Feb 18 13:48:52 2009 From: riegel at clearimageonline.com (Terry Riegel) Date: Wed, 18 Feb 2009 14:48:52 -0500 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: <499C6071.8080207@denhaag.org> References: <499C6071.8080207@denhaag.org> Message-ID: >> So I have this... >> document.getElementById('testform').onsubmit=TestDataCheck; > > Not quite to the point but be aware that IE does not differ between > 'name' > and 'id' namespaces so this will have consequences for your script. I am actually using prototype with the dollar function. From lester at denhaag.org Wed Feb 18 14:01:44 2009 From: lester at denhaag.org (J. Lester Novros II) Date: Wed, 18 Feb 2009 21:01:44 +0100 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: References: <499C6071.8080207@denhaag.org> Message-ID: <499C6928.1050200@denhaag.org> Terry Riegel wrote: > I am actually using prototype with the dollar function. I am not too familiar with that library and syntax, maybe it abstracts away this particular bug. I just thought I give you the heads up since it once took me hours to figure out why my script wasn't working properly and it turned out to be this stupid IE bug. l8R lES -- Microsoft's business practices have fundamentally diminished (in fact, came very close to eliminating) competition, choice and innovation in how people access the Internet. Mitchell Baker - Mozilla Chair http://www.supermarionation.tv From paul at juniperwebcraft.com Wed Feb 18 14:07:25 2009 From: paul at juniperwebcraft.com (Paul Novitski) Date: Wed, 18 Feb 2009 12:07:25 -0800 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: <25178587.1234983941851.JavaMail.root@m01> References: <25178587.1234983941851.JavaMail.root@m01> Message-ID: Hey Terry, At 2/18/2009 11:03 AM, Terry Riegel wrote: >I am working through an unobtrusive bit of javascript and wonder if >anyone might be able to lend a hand. > > onSubmit="return TestDataCheck()"> > >I would like to take this onSubmit out of the form declaration and put >it in an startup function that runs on load. > >So I have this... >document.getElementById('testform').onsubmit=TestDataCheck; >I am not sure of the syntax that would duplicate the return part of >the obtrusive JS. >I have tried this... >document.getElementById('testform').onsubmit=return TestDataCheck; > >How would I get it to invalidate the action of the form and just do >something else? The short answer is that if the javascript function triggered by onSubmit returns FALSE, the form won't submit. Here's one way to do it (below). This code won't crash if it's run in a browser that doesn't support DOM-aware javascript nor if the 'testform' object isn't found. And of course it should go without saying that since you can't trust that javasrcipt will be present to test your form data you need to do it again server-side. Paul _______________________ HTML: JavaScript: // tell js to initialize the form when the page loads AddEvent(window, "load", FormInit); //========================= function FormInit() //========================= // intialize the form { // go away if DOM not supported if (!document.getElementById) return; // apply onsubmit behavior to form object oForm = document.getElementById('testform'); if (oForm) { AddEvent(oForm, "submit", TestDataCheck); } } //========================= function TestDataCheck(evt) //========================= // test the data when the form is submitted { // cancel event-bubbling if (evt) { event = evt; } event.cancelBubble = true; // test the data... bSuccess = ValidateForm(); // display error messages as needed if (!bSuccess) { ... } // if checks failed return FALSE to cancel form submission // if checks are OK return TRUE to allow form submission return bSuccess; } //========================= function AddEvent(oElement, sEventName, fnFunction) //========================= // add an event to the DOM { if (oElement) { if (oElement.attachEvent) { oElement.attachEvent("on" + sEventName, fnFunction); } else { oElement.addEventListener(sEventName, fnFunction, true); } } } From hassan at webtuitive.com Wed Feb 18 13:59:22 2009 From: hassan at webtuitive.com (Hassan Schroeder) Date: Wed, 18 Feb 2009 11:59:22 -0800 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: References: <499C6071.8080207@denhaag.org> Message-ID: <499C689A.3070108@webtuitive.com> Terry Riegel wrote: > I am actually using prototype with the dollar function. In that case, you can use Event.stop(ev) -- see the documentation (and the source) for more info. -- Hassan Schroeder ----------------------------- hassan at webtuitive.com Webtuitive Design === (+1) 408-621-3445 === http://webtuitive.com dream. code. From tedd at sperling.com Wed Feb 18 14:58:51 2009 From: tedd at sperling.com (tedd) Date: Wed, 18 Feb 2009 15:58:51 -0500 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: References: Message-ID: At 2:03 PM -0500 2/18/09, Terry Riegel wrote: >I am working through an unobtrusive bit of javascript and wonder if >anyone might be able to lend a hand. > > onSubmit="return TestDataCheck()"> > >I would like to take this onSubmit out of the form declaration and put >it in an startup function that runs on load. > >So I have this... >document.getElementById('testform').onsubmit=TestDataCheck; >I am not sure of the syntax that would duplicate the return part of >the obtrusive JS. >I have tried this... >document.getElementById('testform').onsubmit=return TestDataCheck; > >How would I get it to invalidate the action of the form and just do >something else? > >Any help will be greatly appreciated. > >Terry Riegel Terry: Here's an example that works as you want: http://www.webbytedd.com/ccc/uob-onsubmit-oneform/index.php The form simply has a name, in this case 'a'. Besides the javascript being loaded via the head, there is no other javascript within the page (except the where it shows the code, but that's for demo only). As is typical, when the pages loads, the javascript is loaded. However, the js script monitors what the html is doing and when the user clicks "submit", javascript takes over and asks for both fields to be filled. BUT please note -- no javascript hooks (i.e., onClick, onSubmit) appears within the html, thus it is Unobtrusive. Kind on neat, huh? :-) HTH's tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.com From philthathril at gmail.com Thu Feb 19 12:22:07 2009 From: philthathril at gmail.com (Philip Thompson) Date: Thu, 19 Feb 2009 12:22:07 -0600 Subject: [Javascript] Unobtrusive onsubmit In-Reply-To: References: Message-ID: <07B197CA-3991-44DA-BB2B-BA4EAB2C84FB@gmail.com> On Feb 18, 2009, at 1:03 PM, Terry Riegel wrote: > I am working through an unobtrusive bit of javascript and wonder if > anyone might be able to lend a hand. > > onSubmit="return TestDataCheck()"> > > I would like to take this onSubmit out of the form declaration and put > it in an startup function that runs on load. > > So I have this... > document.getElementById('testform').onsubmit=TestDataCheck; > I am not sure of the syntax that would duplicate the return part of > the obtrusive JS. > I have tried this... > document.getElementById('testform').onsubmit=return TestDataCheck; > > How would I get it to invalidate the action of the form and just do > something else? > > Any help will be greatly appreciated. > > Terry Riegel Try using an anonymous: document.getElementById('testform').onsubmit = function () { return TestDataCheck(); }; Or, if you are using a library (this is particularly mootools): $('testform').addEvent('submit', function () { return TestDataCheck(); }); HTH, ~Philip From shashankan.10 at gmail.com Fri Feb 20 01:01:09 2009 From: shashankan.10 at gmail.com (shashanka n) Date: Fri, 20 Feb 2009 12:31:09 +0530 Subject: [Javascript] Javascript Digest, Vol 18, Issue 9 In-Reply-To: References: Message-ID: On Thu, Feb 19, 2009 at 11:30 PM, wrote: > Send Javascript mailing list submissions to > javascript at lists.evolt.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.evolt.org/mailman/listinfo/javascript > or, via email, send a message with subject or body 'help' to > javascript-request at lists.evolt.org > > You can reach the person managing the list at > javascript-owner at lists.evolt.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Javascript digest..." > > Today's Topics: > > 1. Unobtrusive onsubmit (Terry Riegel) > 2. Re: Unobtrusive onsubmit (J. Lester Novros II) > 3. Re: Unobtrusive onsubmit (Peter Brunone) > 4. Re: Unobtrusive onsubmit (J. Lester Novros II) > 5. Re: Unobtrusive onsubmit (Terry Riegel) > 6. Re: Unobtrusive onsubmit (J. Lester Novros II) > 7. Re: Unobtrusive onsubmit (Paul Novitski) > 8. Re: Unobtrusive onsubmit (Hassan Schroeder) > 9. Re: Unobtrusive onsubmit (tedd) > > > ---------- Forwarded message ---------- > From: Terry Riegel > To: JavaScript List > Date: Wed, 18 Feb 2009 14:03:09 -0500 > Subject: [Javascript] Unobtrusive onsubmit > I am working through an unobtrusive bit of javascript and wonder if anyone > might be able to lend a hand. > > onSubmit="return TestDataCheck()"> > > I would like to take this onSubmit out of the form declaration and put it > in an startup function that runs on load. > > So I have this... > document.getElementById('testform').onsubmit=TestDataCheck; > I am not sure of the syntax that would duplicate the return part of the > obtrusive JS. > I have tried this... > document.getElementById('testform').onsubmit=return TestDataCheck; > > How would I get it to invalidate the action of the form and just do > something else? > > Any help will be greatly appreciated. > > Terry Riegel > > > > ---------- Forwarded message ---------- > From: "J. Lester Novros II" > To: JavaScript List > Date: Wed, 18 Feb 2009 20:24:33 +0100 > Subject: Re: [Javascript] Unobtrusive onsubmit > Terry, > > Terry Riegel wrote: > >> So I have this... >> document.getElementById('testform').onsubmit=TestDataCheck; >> > > Not quite to the point but be aware that IE does not differ between 'name' > and 'id' namespaces so this will have consequences for your script. > > Just a heads up. > > l8R lES > -- > Microsoft's business practices have fundamentally diminished (in fact, > came very close to eliminating) competition, choice and innovation in > how people access the Internet. Mitchell Baker - Mozilla Chair > http://www.supermarionation.tv > > > > ---------- Forwarded message ---------- > From: "Peter Brunone" > To: "JavaScript List" > Date: Wed, 18 Feb 2009 12:32:04 -0700 > Subject: Re: [Javascript] Unobtrusive onsubmit > > IE does not differ between 'name' > > and 'id' namespaces > > What exactly does that mean? > > ---------------------------------------- > > From: "J. Lester Novros II" > > Terry, > > Terry Riegel wrote: > > So I have this... > > document.getElementById('testform').onsubmit=TestDataCheck; > > Not quite to the point but be aware that IE does not differ between 'name' > > and 'id' namespaces so this will have consequences for your script. > > Just a heads up. > > l8R lES > > > > ---------- Forwarded message ---------- > From: "J. Lester Novros II" > To: JavaScript List > Date: Wed, 18 Feb 2009 20:43:31 +0100 > Subject: Re: [Javascript] Unobtrusive onsubmit > Peter Brunone wrote: > >> IE does not differ between 'name' and 'id' namespaces >>> >> >> What exactly does that mean? >> > > It means that IE will *always* return the element with the corresponding > name rather than the element with the desired id if there are two elements, > one with an 'id' and another with a 'name' that are identical. > > I don't really know what happens when one element has an identical id and > name but I thought to better bring this up than have the script author get > mired in difficult to trace bugs/unwanted script behaviour. > > Also, this came up on the list quite a while ago. Maybe the archives can be > searched for the 'namespace' search term. > > l8R lES > -- > Microsoft's business practices have fundamentally diminished (in fact, > came very close to eliminating) competition, choice and innovation in > how people access the Internet. Mitchell Baker - Mozilla Chair > http://www.supermarionation.tv > > > > ---------- Forwarded message ---------- > From: Terry Riegel > To: JavaScript List > Date: Wed, 18 Feb 2009 14:48:52 -0500 > Subject: Re: [Javascript] Unobtrusive onsubmit > >> So I have this... >>> document.getElementById('testform').onsubmit=TestDataCheck; >>> >> >> Not quite to the point but be aware that IE does not differ between 'name' >> and 'id' namespaces so this will have consequences for your script. >> > > I am actually using prototype with the dollar function. > > > > ---------- Forwarded message ---------- > From: "J. Lester Novros II" > To: JavaScript List > Date: Wed, 18 Feb 2009 21:01:44 +0100 > Subject: Re: [Javascript] Unobtrusive onsubmit > Terry Riegel wrote: > >> I am actually using prototype with the dollar function. >> > > I am not too familiar with that library and syntax, maybe it abstracts away > this particular bug. > > I just thought I give you the heads up since it once took me hours to > figure out why my script wasn't working properly and it turned out to be > this stupid IE bug. > > l8R lES > -- > Microsoft's business practices have fundamentally diminished (in fact, > came very close to eliminating) competition, choice and innovation in > how people access the Internet. Mitchell Baker - Mozilla Chair > http://www.supermarionation.tv > > > > ---------- Forwarded message ---------- > From: Paul Novitski > To: JavaScript List > Date: Wed, 18 Feb 2009 12:07:25 -0800 > Subject: Re: [Javascript] Unobtrusive onsubmit > Hey Terry, > > At 2/18/2009 11:03 AM, Terry Riegel wrote: > >> I am working through an unobtrusive bit of javascript and wonder if >> anyone might be able to lend a hand. >> >> > onSubmit="return TestDataCheck()"> >> >> I would like to take this onSubmit out of the form declaration and put >> it in an startup function that runs on load. >> >> So I have this... >> document.getElementById('testform').onsubmit=TestDataCheck; >> I am not sure of the syntax that would duplicate the return part of >> the obtrusive JS. >> I have tried this... >> document.getElementById('testform').onsubmit=return TestDataCheck; >> >> How would I get it to invalidate the action of the form and just do >> something else? >> > > > The short answer is that if the javascript function triggered by onSubmit > returns FALSE, the form won't submit. > > Here's one way to do it (below). This code won't crash if it's run in a > browser that doesn't support DOM-aware javascript nor if the 'testform' > object isn't found. > > And of course it should go without saying that since you can't trust that > javasrcipt will be present to test your form data you need to do it again > server-side. > > Paul > _______________________ > > > HTML: > > > > JavaScript: > > // tell js to initialize the form when the page loads > AddEvent(window, "load", FormInit); > > > //========================= > function FormInit() > //========================= > // intialize the form > { > // go away if DOM not supported > if (!document.getElementById) return; > > // apply onsubmit behavior to form object > oForm = document.getElementById('testform'); > > if (oForm) > { > AddEvent(oForm, "submit", TestDataCheck); > } > } > > > //========================= > function TestDataCheck(evt) > //========================= > // test the data when the form is submitted > { > // cancel event-bubbling > if (evt) { event = evt; } > event.cancelBubble = true; > > // test the data... > bSuccess = ValidateForm(); > > // display error messages as needed > if (!bSuccess) > { > ... > } > > // if checks failed return FALSE to cancel form submission > // if checks are OK return TRUE to allow form submission > return bSuccess; > } > > > //========================= > function AddEvent(oElement, sEventName, fnFunction) > //========================= > // add an event to the DOM > { > if (oElement) > { > if (oElement.attachEvent) > { > oElement.attachEvent("on" + sEventName, fnFunction); > } > else > { > oElement.addEventListener(sEventName, fnFunction, > true); > } > } > } > > > > > ---------- Forwarded message ---------- > From: Hassan Schroeder > To: JavaScript List > Date: Wed, 18 Feb 2009 11:59:22 -0800 > Subject: Re: [Javascript] Unobtrusive onsubmit > Terry Riegel wrote: > > I am actually using prototype with the dollar function. >> > > In that case, you can use Event.stop(ev) -- see the documentation > (and the source) for more info. > > -- > Hassan Schroeder ----------------------------- hassan at webtuitive.com > Webtuitive Design === (+1) 408-621-3445 === http://webtuitive.com > > dream. code. > > > > ---------- Forwarded message ---------- > From: tedd > To: JavaScript List > Date: Wed, 18 Feb 2009 15:58:51 -0500 > Subject: Re: [Javascript] Unobtrusive onsubmit > At 2:03 PM -0500 2/18/09, Terry Riegel wrote: > >> I am working through an unobtrusive bit of javascript and wonder if anyone >> might be able to lend a hand. >> >> > onSubmit="return TestDataCheck()"> >> >> I would like to take this onSubmit out of the form declaration and put it >> in an startup function that runs on load. >> >> So I have this... >> document.getElementById('testform').onsubmit=TestDataCheck; >> I am not sure of the syntax that would duplicate the return part of the >> obtrusive JS. >> I have tried this... >> document.getElementById('testform').onsubmit=return TestDataCheck; >> >> How would I get it to invalidate the action of the form and just do >> something else? >> >> Any help will be greatly appreciated. >> >> Terry Riegel >> > > Terry: > > Here's an example that works as you want: > > http://www.webbytedd.com/ccc/uob-onsubmit-oneform/index.php > > The form simply has a name, in this case 'a'. Besides the javascript being > loaded via the head, there is no other javascript within the page (except > the where it shows the code, but that's for demo only). > > As is typical, when the pages loads, the javascript is loaded. However, the > js script monitors what the html is doing and when the user clicks "submit", > javascript takes over and asks for both fields to be filled. BUT please note > -- no javascript hooks (i.e., onClick, onSubmit) appears within the html, > thus it is Unobtrusive. Kind on neat, huh? :-) > > HTH's > > tedd > > -- > ------- > http://sperling.com http://ancientstones.com http://earthstones.com > > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > I am using something like this for the desired functionality : In HTML: or In JS : document.body.onload=Pageload at the end of your document then, ThisClass.Pageload=function() { //Stuff to do when the pageload happens... } -- - Warm regards Shashanka N From riegel at clearimageonline.com Wed Feb 25 10:20:23 2009 From: riegel at clearimageonline.com (Terry Riegel) Date: Wed, 25 Feb 2009 11:20:23 -0500 Subject: [Javascript] Targeting the correct form?? Message-ID: Hello everyone. I am struggling with a particular function. I have a page with multiple forms on it. I am applying unobtrusive javascript to it and am having difficulty targeting the right form with my code. Via an onload I call forms() and that works great. When I go to submit the form I simply alert the id of the form submitted. At least thats what I would think my code would do (listed below). Instead regardless of what form button I click on It alerts the id of the last form element on the page. Any help will be greatly appreciated. function forms(h) { var daItems = $$('.'+h); for (iItem=0; iItem < daItems.length; iItem++) { var o=daItems[iItem] o.onsubmit=function(){return doforms(o)}; } } function doforms(o) { alert(o.id); return false; } The Markup for the three forms look like this...
From Mark.Rees at astrazeneca.com Wed Feb 25 10:44:53 2009 From: Mark.Rees at astrazeneca.com (Rees, Mark) Date: Wed, 25 Feb 2009 16:44:53 -0000 Subject: [Javascript] Iframe: load same URL using JS Message-ID: Hello This doesn't work, and it doesn't work in HTML either. A single iframe is created OK but it is empty. I suppose there is some security feature in browsers to stop infinite page loads? The thing is I only wish to do it once (as the code below shows). Just curious as to what is stopping it working. function addIframe(){ //reloads the same page in an iframe if(!document.getElementById('iframe')){ var iFrame=document.createElement('iframe'); iFrame.width=100; iFrame.height=100; //for some reason you cannot reload the same page in the parent iFrame.src=location.href; iFrame.setAttribute('id','iframe'); document.body.appendChild(iFrame); } } function checkIframe(){ //checks whether there is already an iframe if(!window.frameElement){ alert('i am the parent page'); addIframe(); }else{ //this never runs alert('i am the child page'); } } window.onload=checkIframe; Mark -------------------------------------------------------------------------- AstraZeneca UK Limited is a company incorporated in England and Wales with registered number: 03674842 and a registered office at 15 Stanhope Gate, London W1K 1LN. Confidentiality Notice: This message is private and may contain confidential, proprietary and legally privileged information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorised use or disclosure of the contents of this message is not permitted and may be unlawful. Disclaimer: Email messages may be subject to delays, interception, non-delivery and unauthorised alterations. Therefore, information expressed in this message is not given or endorsed by AstraZeneca UK Limited unless otherwise notified by an authorised representative independent of this message. No contractual relationship is created by this message by any person unless specifically indicated by agreement in writing other than email. Monitoring: AstraZeneca UK Limited may monitor email traffic data and content for the purposes of the prevention and detection of crime, ensuring the security of our computer systems and checking Compliance with our Code of Conduct and Policies. From david at dorward.me.uk Wed Feb 25 11:07:35 2009 From: david at dorward.me.uk (David Dorward) Date: Wed, 25 Feb 2009 17:07:35 +0000 Subject: [Javascript] Targeting the correct form?? In-Reply-To: References: Message-ID: <49A57AD7.9090508@dorward.me.uk> Terry Riegel wrote: > Hello everyone. I am struggling with a particular function. I have a > page with multiple forms on it. I am applying unobtrusive javascript > to it and am having difficulty targeting the right form with my code. > Via an onload I call forms() and that works great. When I go to submit > the form I simply alert the id of the form submitted. At least thats > what I would think my code would do (listed below). Instead regardless > of what form button I click on It alerts the id of the last form > element on the page. > This is a common error. > Any help will be greatly appreciated. > > > function forms(h) { > var daItems = $$('.'+h); > for (iItem=0; iItem < daItems.length; iItem++) { > var o=daItems[iItem] > o.onsubmit=function(){return doforms(o)}; > } > } > > function doforms(o) { > alert(o.id); > return false; > } > When you assign function(){return doforms(o)};, "o" means "The variable o" not "The current value of the variable o". Since the loop keeps going - o ends up being the last value that it reaches by the time the function is ever called. I could explain how to use closures to work around this, but its much simpler to just suggest you use this instead. o.onsubmit=function(){return doforms(this)}; Or even easier: var doforms = function () { alert(this.id); return false; }; and o.onsubmit=doforms; And just for good measure, insert rant about obfuscated code: http://dorward.tumblr.com/post/79674407/the-dollar-function-must-die -- David Dorward http://dorward.me.uk/ From riegel at clearimageonline.com Wed Feb 25 13:07:23 2009 From: riegel at clearimageonline.com (Terry Riegel) Date: Wed, 25 Feb 2009 14:07:23 -0500 Subject: [Javascript] Targeting the correct form?? In-Reply-To: <49A57AD7.9090508@dorward.me.uk> References: <49A57AD7.9090508@dorward.me.uk> Message-ID: <85E37A87-6F53-4757-8C11-D6A1B9FE3E03@clearimageonline.com> David, Thanks for your reply. I think I have been caught with this several times over the years and for some reason can't get my head around it. I know I have asked questions like this on this exact same issue in the past and this group (possibly you) have been very kind to answer. I do have one followup question... I tried both of your methods but only one worked. Any idea what was wrong with the second I listed here... Perhaps is something obvious I am missing. This one worked ---------------- function forms(h) { var daItems = $$('.'+h); for (iItem=0; iItem < daItems.length; iItem++) { var o=daItems[iItem] o.onsubmit=doforms; } } var doforms = function() { alert(this.id); return false; } This one did not work --------------------- function forms(h) { var daItems = $$('.'+h); for (iItem=0; iItem < daItems.length; iItem++) { var o=daItems[iItem] o.onsubmit=function(){return doforms(this)}; } } function doforms() { alert(this); return false; } Thanks again, Terry On Feb 25, 2009, at 12:07 PM, David Dorward wrote: > Terry Riegel wrote: >> Hello everyone. I am struggling with a particular function. I have a >> page with multiple forms on it. I am applying unobtrusive javascript >> to it and am having difficulty targeting the right form with my code. >> Via an onload I call forms() and that works great. When I go to >> submit >> the form I simply alert the id of the form submitted. At least thats >> what I would think my code would do (listed below). Instead >> regardless >> of what form button I click on It alerts the id of the last form >> element on the page. >> > This is a common error. > >> Any help will be greatly appreciated. >> >> >> function forms(h) { >> var daItems = $$('.'+h); >> for (iItem=0; iItem < daItems.length; iItem++) { >> var o=daItems[iItem] >> o.onsubmit=function(){return doforms(o)}; >> } >> } >> >> function doforms(o) { >> alert(o.id); >> return false; >> } >> > > When you assign function(){return doforms(o)};, "o" means "The > variable > o" not "The current value of the variable o". > > Since the loop keeps going - o ends up being the last value that it > reaches by the time the function is ever called. > > I could explain how to use closures to work around this, but its much > simpler to just suggest you use this instead. > > o.onsubmit=function(){return doforms(this)}; > > > Or even easier: > var doforms = function () { > alert(this.id); > return false; > }; > > and > o.onsubmit=doforms; > > > And just for good measure, insert rant about obfuscated code: > http://dorward.tumblr.com/post/79674407/the-dollar-function-must-die > > -- > David Dorward > http://dorward.me.uk/ > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript From paul at juniperwebcraft.com Wed Feb 25 13:40:25 2009 From: paul at juniperwebcraft.com (Paul Novitski) Date: Wed, 25 Feb 2009 11:40:25 -0800 Subject: [Javascript] Targeting the correct form?? In-Reply-To: <31470512.1235588988805.JavaMail.root@m01> References: <49A57AD7.9090508@dorward.me.uk> <31470512.1235588988805.JavaMail.root@m01> Message-ID: At 2/25/2009 11:07 AM, Terry Riegel wrote: >This one worked >---------------- >function forms(h) { > var daItems = $$('.'+h); > for (iItem=0; iItem < daItems.length; iItem++) { > var o=daItems[iItem] > o.onsubmit=doforms; > } >} > > var doforms = function() { > alert(this.id); > return false; > } > > >This one did not work >--------------------- >function forms(h) { > var daItems = $$('.'+h); > for (iItem=0; iItem < daItems.length; iItem++) { > var o=daItems[iItem] > o.onsubmit=function(){return doforms(this)}; > } >} > >function doforms() { > alert(this); > return false; > } Terry, An important question to ask yourself when considering the code is: what does 'this' (or any function argument) represent when it's applied to a behavior trigger, and what does it represent when the function is later called? When a function is called as the result of an event, 'this' refers to the object whose event has just occurred. In your second example above, the one that did not work, in function forms(h){} I'm not really sure what, if anything, 'this' refers to, but it's certainly not some specific form being triggered sometime in the future. When you're creating a function on the fly, its arguments take their current value (in the moment that the function is being created) and not their hypothetical value sometime later when the function is called. It seems to me that the main reason your second example doesn't work is that you're calling "alert(this);" instead of "alert(this.id);" as you do in your first example. Trying to display an object with alert() won't get you much valuable information, but displaying an Id might. Passing 'this' to the doforms() function in your second example is just a red herring and doesn't accomplish anything that I can see. It certainly isn't affecting the meaning of 'this' inside doforms(). Clear as mud? By the way, I'm not sure why you're using the variable 'o' to point to the form object for a few milli- or microseconds: var o=daItems[iItem] o.onsubmit=doforms; You could simply write: daItems[iItem].onsubmit=doforms; since daItems[iItem] is a perfectly legal representation for the form object. The only reason I would use a temporary variable as you're doing would be if I needed to test it to make sure it's really there, you know, like: var o=daItems[iItem] if (!o) continue; o.onsubmit=doforms; But your code has PRESUMABLY already guaranteed that each item in your array is indeed a form object. Of course, your code doesn't make it clear HOW you know that daItems are actually forms. Like David, I really dislike the $ syntax. My attitude is that scripting languages are for people, not computers. If your code isn't easy for you to read today, or you to read a year from now, or for someone else to read next week when you get hit by the proverbial sudden need to escape to Tahiti, you might as well just write in machine language which will be just as human-unreadable but at least will execute significantly faster. Regards, Paul __________________________ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com From pp.koch at gmail.com Wed Feb 25 15:13:03 2009 From: pp.koch at gmail.com (Peter-Paul Koch) Date: Wed, 25 Feb 2009 22:13:03 +0100 Subject: [Javascript] Iframe: load same URL using JS In-Reply-To: References: Message-ID: <21e4a1280902251313r44c8539ey6b84cc941abbb96a@mail.gmail.com> You didn't specify the browser. Nonetheless, at a total guess, try appending the iframe before setting the src. It just might work. 2009/2/25 Rees, Mark : > Hello > > This doesn't work, and it doesn't work in HTML either. A single iframe is created OK but it is empty. > > I suppose there is some security feature in browsers to stop infinite page loads? The thing is I only wish to do it once (as the code below shows). Just curious as to what is stopping it working. > > function addIframe(){ > ? ? ? ?//reloads the same page in an iframe > ? ? ? ?if(!document.getElementById('iframe')){ > ? ? ? ? ? ? ? ?var iFrame=document.createElement('iframe'); > ? ? ? ? ? ? ? ?iFrame.width=100; > ? ? ? ? ? ? ? ?iFrame.height=100; > ? ? ? ? ? ? ? ?//for some reason you cannot reload the same page in the parent > > ? ? ? ? ? ? ? ?iFrame.src=location.href; > > ? ? ? ? ? ? ? ?iFrame.setAttribute('id','iframe'); > ? ? ? ? ? ? ? ?document.body.appendChild(iFrame); > ? ? ? ?} > } > > function checkIframe(){ > ? ? ? ?//checks whether there is already an iframe > ? ? ? ?if(!window.frameElement){ > ? ? ? ? ? ? ? ?alert('i am the parent page'); > ? ? ? ? ? ? ? ?addIframe(); > > > > ? ? ? ?}else{ > ? ? ? ? ? ? ? ?//this never runs > ? ? ? ? ? ? ? ?alert('i am the child page'); > > ? ? ? ?} > } > > window.onload=checkIframe; > > Mark > > -------------------------------------------------------------------------- > AstraZeneca UK Limited is a company incorporated in England and Wales with registered number: 03674842 and a registered office at 15 Stanhope Gate, London W1K 1LN. > Confidentiality Notice: This message is private and may contain confidential, proprietary and legally privileged information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorised use or disclosure of the contents of this message is not permitted and may be unlawful. > Disclaimer: Email messages may be subject to delays, interception, non-delivery and unauthorised alterations. Therefore, information expressed in this message is not given or endorsed by AstraZeneca UK Limited unless otherwise notified by an authorised representative independent of this message. No contractual relationship is created by this message by any person unless specifically indicated by agreement in writing other than email. > Monitoring: AstraZeneca UK Limited may monitor email traffic data and content for the purposes of the prevention and detection of crime, ensuring the security of our computer systems and checking Compliance with our Code of Conduct and Policies. > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > -- ------------------------------------------------------------------- ppk, freelance front-end consultant, agent, and trainer http://www.quirksmode.org/about/ ------------------------------------------------------------------ From Mark.Rees at astrazeneca.com Thu Feb 26 07:49:49 2009 From: Mark.Rees at astrazeneca.com (Rees, Mark) Date: Thu, 26 Feb 2009 13:49:49 -0000 Subject: [Javascript] Iframe: load same URL using JS In-Reply-To: <21e4a1280902251313r44c8539ey6b84cc941abbb96a@mail.gmail.com> Message-ID: Sorry, I should have mentioned that the original code doesn't work in IE6 or FF3 on Win2K. Your suggestion doesn't work either - in fact it throws an error in Firefox on the line when you try to set the src like so: uncaught exception: [Exception... "Component returned failure code: 0x8000ffff (NS_ERROR_UNEXPECTED) [nsIDOMHTMLIFrameElement.src]" nsresult: "0x8000ffff (NS_ERROR_UNEXPECTED)" location: "JS frame :: file:///C:/mark/test.htm :: addIframe :: line 25" data: no] What I have noticed is that setting the src to the current URL as a string works in IE: iFrame.src='http://this.url'; but not in Firefox Not a big problem as I can always use another page instead of the same one. I'm just a bit surprised that this isn't possible although I can quite see why it shouldn't be. -------------------------------------------------------------------------- AstraZeneca UK Limited is a company incorporated in England and Wales with registered number: 03674842 and a registered office at 15 Stanhope Gate, London W1K 1LN. Confidentiality Notice: This message is private and may contain confidential, proprietary and legally privileged information. If you have received this message in error, please notify us and remove it from your system and note that you must not copy, distribute or take any action in reliance on it. Any unauthorised use or disclosure of the contents of this message is not permitted and may be unlawful. Disclaimer: Email messages may be subject to delays, interception, non-delivery and unauthorised alterations. Therefore, information expressed in this message is not given or endorsed by AstraZeneca UK Limited unless otherwise notified by an authorised representative independent of this message. No contractual relationship is created by this message by any person unless specifically indicated by agreement in writing other than email. Monitoring: AstraZeneca UK Limited may monitor email traffic data and content for the purposes of the prevention and detection of crime, ensuring the security of our computer systems and checking Compliance with our Code of Conduct and Policies. -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org]On Behalf Of Peter-Paul Koch Sent: 25 February 2009 21:13 To: JavaScript List Subject: Re: [Javascript] Iframe: load same URL using JS You didn't specify the browser. Nonetheless, at a total guess, try appending the iframe before setting the src. It just might work. 2009/2/25 Rees, Mark : > Hello > > This doesn't work, and it doesn't work in HTML either. A single iframe is created OK but it is empty. > > I suppose there is some security feature in browsers to stop infinite page loads? The thing is I only wish to do it once (as the code below shows). Just curious as to what is stopping it working. > > function addIframe(){ > //reloads the same page in an iframe > if(!document.getElementById('iframe')){ > var iFrame=document.createElement('iframe'); > iFrame.width=100; > iFrame.height=100; > //for some reason you cannot reload the same page in the parent > > iFrame.src=location.href; > > iFrame.setAttribute('id','iframe'); > document.body.appendChild(iFrame); > } > } > > function checkIframe(){ > //checks whether there is already an iframe > if(!window.frameElement){ > alert('i am the parent page'); > addIframe(); > > > > }else{ > //this never runs > alert('i am the child page'); > > } > } > > window.onload=checkIframe; > > Mark From schneegans at internetique.com Thu Feb 26 09:10:30 2009 From: schneegans at internetique.com (Claude Schneegans) Date: Thu, 26 Feb 2009 10:10:30 -0500 Subject: [Javascript] Looking for some super_focus() Message-ID: <49A6B0E6.3020204@internetique.com> Hi, I have an application which opens a couple of windows. From one window, some link may update another windows. When refreshed, this other window will come on top thanks to a call to focus(). Everything works well. However, I've noticed that if the user choses to have IE open new tabs instead of new windows, the focus() function does not make the tab to open. It will only become reddish and the user has to click on it in order to open it. Is there another method I can user to make sure the tab really opens? From riegel at clearimageonline.com Thu Feb 26 15:10:44 2009 From: riegel at clearimageonline.com (Terry Riegel) Date: Thu, 26 Feb 2009 16:10:44 -0500 Subject: [Javascript] Input type="image" Message-ID: Hello all, I have an input type="image" and when it submits its ends along the x and y coordinate of the place it was clicked. Is there a way to get that information client side with javascript? Thanks, Terry From brett.stinson at gmail.com Thu Feb 26 21:08:02 2009 From: brett.stinson at gmail.com (Brett Stinson) Date: Thu, 26 Feb 2009 21:08:02 -0600 Subject: [Javascript] Input type="image" In-Reply-To: References: Message-ID: <49a7591a.14b48c0a.567c.fffff0cb@mx.google.com> Use the getMouseXY function from the script on this page in your onclick for the image: http://javascript.internet.com/page-details/mouse-coordinates.html Brett Stinson brett.stinson at gmail.com -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Terry Riegel Sent: Thursday, February 26, 2009 3:11 PM To: JavaScript List Subject: [Javascript] Input type="image" Hello all, I have an input type="image" and when it submits its ends along the x and y coordinate of the place it was clicked. Is there a way to get that information client side with javascript? Thanks, Terry _______________________________________________ Javascript mailing list Javascript at lists.evolt.org http://lists.evolt.org/mailman/listinfo/javascript From trojani2000 at hotmail.com Thu Feb 26 21:46:44 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Fri, 27 Feb 2009 03:46:44 +0000 Subject: [Javascript] Iframe: load same URL using JS In-Reply-To: References: Message-ID: > Mark: > This doesn't work, and it doesn't work in HTML either. A single > iframe is created OK but it is empty. When something is not working in a simple plain HTML, it is futile to persist in trying to make it work through dhtml. p.s.: Might be security restriction, but I doubt it. Because IFRAME is a documentElement if I'm not wrong, and loading the same content in both will exactly yield an infinity parallel mirror effect,... Regards, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Wed, 25 Feb 2009 16:44:53 +0000 > From: Mark.Rees at astrazeneca.com > To: javascript at lists.evolt.org > Subject: [Javascript] Iframe: load same URL using JS > > Hello > > This doesn't work, and it doesn't work in HTML either. A single iframe is created OK but it is empty. > > I suppose there is some security feature in browsers to stop infinite page loads? The thing is I only wish to do it once (as the code below shows). Just curious as to what is stopping it working. > > function addIframe(){ > //reloads the same page in an iframe > if(!document.getElementById('iframe')){ > var iFrame=document.createElement('iframe'); > iFrame.width=100; > iFrame.height=100; > //for some reason you cannot reload the same page in the parent > > iFrame.src=location.href; > > iFrame.setAttribute('id','iframe'); > document.body.appendChild(iFrame); > } > } > > function checkIframe(){ > //checks whether there is already an iframe > if(!window.frameElement){ > alert('i am the parent page'); > addIframe(); > > > > }else{ > //this never runs > alert('i am the child page'); > > } > } > > window.onload=checkIframe; > > Mark _________________________________________________________________ Windows Live? Hotmail??more than just e-mail. http://windowslive.com/howitworks?ocid=TXT_TAGLM_WL_t2_hm_justgotbetter_howitworks_022009 From trojani2000 at hotmail.com Fri Feb 27 09:23:12 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Fri, 27 Feb 2009 15:23:12 +0000 Subject: [Javascript] Targeting the correct form?? In-Reply-To: <85E37A87-6F53-4757-8C11-D6A1B9FE3E03@clearimageonline.com> References: <49A57AD7.9090508@dorward.me.uk> <85E37A87-6F53-4757-8C11-D6A1B9FE3E03@clearimageonline.com> Message-ID: Hi Terry The working example: > function forms(h) { > var daItems = $$('.'+h); > for (iItem=0; iItem < daItems.length; iItem++) { > var o=daItems[iItem] > o.onsubmit=doforms; > } > } > > var doforms = function() { > alert(this.id); > return false; > } is (almost) equal to: o.onsubmit=function(){alert(this.id);return false;} and it'll work, since you are alerting the returned string of the this[object].id.value, belonging to current o.[variable] reference/object. But, you are overdoing it, because "var doforms", is not necessary if you go: function doforms(), since "doforms" is nothing but a function variable name. So the: "var doforms = function()" is just another syntax of saying exactly: "function doforms()" (except for these 4 to 7 extra characters of wasted bandwidth). :) The reason why the other one is not working is the following: o.onsubmit=function(){return doforms(this)}; function doforms() {alert(this);return false;} * alert(this) // will allways report itself as: [object], although empty! The following 3 examples, will all work... example 1: ... o.onsubmit=doforms; function doforms() {alert(this.id);return false;} example 2: [more like the one you are using] ... o.onsubmit=function(){return doforms(this)} function doforms(f) {alert(f.id);return false} example 3: ... o.onsubmit=function(){doforms(this); return false} function doforms(f){alert(f.id)} Meaning: "this" keyword never made it to the "doforms function". Regards. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > From: riegel at clearimageonline.com > To: javascript at lists.evolt.org > Date: Wed, 25 Feb 2009 14:07:23 -0500 > Subject: Re: [Javascript] Targeting the correct form?? > > David, > > Thanks for your reply. I think I have been caught with this several > times over the years and for some reason can't get my head around it. > I know I have asked questions like this on this exact same issue in > the past and this group (possibly you) have been very kind to answer. > > I do have one followup question... > > I tried both of your methods but only one worked. Any idea what was > wrong with the second I listed here... > > Perhaps is something obvious I am missing. > > > > This one worked > ---------------- > function forms(h) { > var daItems = $$('.'+h); > for (iItem=0; iItem < daItems.length; iItem++) { > var o=daItems[iItem] > o.onsubmit=doforms; > } > } > > var doforms = function() { > alert(this.id); > return false; > } > > > This one did not work > --------------------- > function forms(h) { > var daItems = $$('.'+h); > for (iItem=0; iItem < daItems.length; iItem++) { > var o=daItems[iItem] > o.onsubmit=function(){return doforms(this)}; > } > } > > function doforms() { > alert(this); > return false; > } > > > > Thanks again, > > Terry > > > > > On Feb 25, 2009, at 12:07 PM, David Dorward wrote: > > > Terry Riegel wrote: > >> Hello everyone. I am struggling with a particular function. I have a > >> page with multiple forms on it. I am applying unobtrusive javascript > >> to it and am having difficulty targeting the right form with my code. > >> Via an onload I call forms() and that works great. When I go to > >> submit > >> the form I simply alert the id of the form submitted. At least thats > >> what I would think my code would do (listed below). Instead > >> regardless > >> of what form button I click on It alerts the id of the last form > >> element on the page. > >> > > This is a common error. > > > >> Any help will be greatly appreciated. > >> > >> > >> function forms(h) { > >> var daItems = $$('.'+h); > >> for (iItem=0; iItem < daItems.length; iItem++) { > >> var o=daItems[iItem] > >> o.onsubmit=function(){return doforms(o)}; > >> } > >> } > >> > >> function doforms(o) { > >> alert(o.id); > >> return false; > >> } > >> > > > > When you assign function(){return doforms(o)};, "o" means "The > > variable > > o" not "The current value of the variable o". > > > > Since the loop keeps going - o ends up being the last value that it > > reaches by the time the function is ever called. > > > > I could explain how to use closures to work around this, but its much > > simpler to just suggest you use this instead. > > > > o.onsubmit=function(){return doforms(this)}; > > > > > > Or even easier: > > var doforms = function () { > > alert(this.id); > > return false; > > }; > > > > and > > o.onsubmit=doforms; > > > > > > And just for good measure, insert rant about obfuscated code: > > http://dorward.tumblr.com/post/79674407/the-dollar-function-must-die > > > > -- > > David Dorward > > http://dorward.me.uk/ > > _______________________________________________ > > Javascript mailing list > > Javascript at lists.evolt.org > > http://lists.evolt.org/mailman/listinfo/javascript > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ It?s the same Hotmail?. If by ?same? you mean up to 70% faster. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_AE_Same_022009