From talofo at gmail.com Mon Mar 2 06:16:02 2009 From: talofo at gmail.com (MEM) Date: Mon, 2 Mar 2009 12:16:02 -0000 Subject: [Javascript] Try and Catch Question Message-ID: <000101c99b30$a7fb9cb0$f7f2d610$@com> Hi all, this is my first post, (so if anything is not right in the way I post, please let me know). When we use a try catch statement like this: try { } catch (e) { } Why do we need the ?e? ? Well, I have seen also with ?err? etc, so I presume the point is to have only something that represents the name error. But, what for? I mean, normally in this kind of statements I never see that ?e? or ?err? being used for nothing, I see no e=?ups error? or something. So, what is that e for? Thanks a lot, M?rcio From john at jwarner.com Mon Mar 2 06:49:02 2009 From: john at jwarner.com (John Warner) Date: Mon, 2 Mar 2009 07:49:02 -0500 Subject: [Javascript] Try and Catch Question In-Reply-To: <000101c99b30$a7fb9cb0$f7f2d610$@com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> Message-ID: <00dc01c99b35$43f82e40$cbe88ac0$@com> (e) allows your catch block to indentify the exception thrown. In some try blocks more than one thing can go wrong, you might choose to ignore some errors but want to respond to others. John Warner > -----Original Message----- > From: javascript-bounces at lists.evolt.org [mailto:javascript- > bounces at lists.evolt.org] On Behalf Of MEM > Sent: Monday, March 02, 2009 7:16 AM > To: javascript at lists.evolt.org > Subject: [Javascript] Try and Catch Question > > Hi all, this is my first post, (so if anything is not right in the way I > post, please let me know). > > > > > > When we use a try catch statement like this: > > try { > > > > } catch (e) { > > > > } > > > > Why do we need the ?e? ? > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > only something that represents the name error. But, what for? I mean, > normally in this kind of statements I never see that ?e? or ?err? being used > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > > > Thanks a lot, > > M?rcio > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript From talofo at gmail.com Mon Mar 2 07:51:35 2009 From: talofo at gmail.com (MEM) Date: Mon, 2 Mar 2009 13:51:35 -0000 Subject: [Javascript] Try and Catch Question In-Reply-To: <00dc01c99b35$43f82e40$cbe88ac0$@com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <00dc01c99b35$43f82e40$cbe88ac0$@com> Message-ID: <000a01c99b3e$016d7cc0$04487640$@com> Ok... we have to have patience with me, sorry, here it goes: So you are saying that the (e) is there so we can identify what as being thrown. Why? Because if we identify what as being thrown we can use that identifier somehow, for example, If "we want to ignore some errors but we want to respond to others". Is this assumption correct? The fact that we cannot have a catch() without something inside is because we are not defining WHAT we want to catch, but that supposes that, with a catch(), we can catch more than exceptions. Right? But is that really important to distinguish what kind of catch are we having there? I mean, since the procedure is the same for no matter what is catch by the catch function, why can't we have a simple catch(), for the cases that we don't want to distinguish the exceptions? I'm sure someone have thinking this before, and there is a reason why we cannot have catch() alone. That's probably the main reason why I can't fully understand, in some cases, (because the other cases you have already told me) why oh why, we need something inside the (). Ps- I've really search on the net for this, but it seems like everybody explains how to do the "try catch" thing, but they don't explain properly what each part of the "try catch" really means. Thanks a lot once again, M?rcio -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org] On Behalf Of John Warner Sent: segunda-feira, 2 de Mar?o de 2009 12:49 To: 'JavaScript List' Subject: Re: [Javascript] Try and Catch Question (e) allows your catch block to indentify the exception thrown. In some try blocks more than one thing can go wrong, you might choose to ignore some errors but want to respond to others. John Warner > -----Original Message----- > From: javascript-bounces at lists.evolt.org [mailto:javascript- > bounces at lists.evolt.org] On Behalf Of MEM > Sent: Monday, March 02, 2009 7:16 AM > To: javascript at lists.evolt.org > Subject: [Javascript] Try and Catch Question > > Hi all, this is my first post, (so if anything is not right in the way I > post, please let me know). > > > > > > When we use a try catch statement like this: > > try { > > > > } catch (e) { > > > > } > > > > Why do we need the ?e? ? > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > only something that represents the name error. But, what for? I mean, > normally in this kind of statements I never see that ?e? or ?err? being used > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > > > Thanks a lot, > > M?rcio > > _______________________________________________ > 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 From xandercoded at gmail.com Mon Mar 2 09:46:32 2009 From: xandercoded at gmail.com (Alexander Freiria) Date: Mon, 2 Mar 2009 10:46:32 -0500 Subject: [Javascript] Try and Catch Question In-Reply-To: <000a01c99b3e$016d7cc0$04487640$@com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <00dc01c99b35$43f82e40$cbe88ac0$@com> <000a01c99b3e$016d7cc0$04487640$@com> Message-ID: I am a C# .NET developer. I know that there are different types of objects that are thrown... Given this, it is possible to check the type of object thrown and react in different ways... For the how that this is done in Javascript I am not too sure. An example of this would be nice. On Mon, Mar 2, 2009 at 8:51 AM, MEM wrote: > Ok... we have to have patience with me, sorry, here it goes: > > So you are saying that the (e) is there so we can identify what as being > thrown. Why? Because if we identify what as being thrown we can use that > identifier somehow, for example, > If "we want to ignore some errors but we want to respond to others". Is > this > assumption correct? > > The fact that we cannot have a catch() without something inside is because > we are not defining WHAT we want to catch, but that supposes that, with a > catch(), we can catch more than exceptions. Right? > But is that really important to distinguish what kind of catch are we > having > there? I mean, since the procedure is the same for no matter what is catch > by the catch function, why can't we have a simple catch(), for the cases > that we don't want to distinguish the exceptions? I'm sure someone have > thinking this before, and there is a reason why we cannot have catch() > alone. That's probably the main reason why I can't fully understand, in > some > cases, (because the other cases you have already told me) why oh why, we > need something inside the (). > > > Ps- I've really search on the net for this, but it seems like everybody > explains how to do the "try catch" thing, but they don't explain properly > what each part of the "try catch" really means. > > > Thanks a lot once again, > M?rcio > > > -----Original Message----- > From: javascript-bounces at lists.evolt.org > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of John Warner > Sent: segunda-feira, 2 de Mar?o de 2009 12:49 > To: 'JavaScript List' > Subject: Re: [Javascript] Try and Catch Question > > (e) allows your catch block to indentify the exception thrown. In some try > blocks more than one thing can go wrong, you might choose to ignore some > errors but want to respond to others. > > John Warner > > > > -----Original Message----- > > From: javascript-bounces at lists.evolt.org [mailto:javascript- > > bounces at lists.evolt.org] On Behalf Of MEM > > Sent: Monday, March 02, 2009 7:16 AM > > To: javascript at lists.evolt.org > > Subject: [Javascript] Try and Catch Question > > > > Hi all, this is my first post, (so if anything is not right in the way I > > post, please let me know). > > > > > > > > > > > > When we use a try catch statement like this: > > > > try { > > > > > > > > } catch (e) { > > > > > > > > } > > > > > > > > Why do we need the ?e? ? > > > > > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > > only something that represents the name error. But, what for? I mean, > > normally in this kind of statements I never see that ?e? or ?err? being > used > > for nothing, I see no e=?ups error? or something. So, what is that e > for? > > > > > > > > > > > > Thanks a lot, > > > > M?rcio > > > > _______________________________________________ > > 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 > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > From peter at brunone.com Mon Mar 2 10:25:54 2009 From: peter at brunone.com (Peter Brunone) Date: Mon, 2 Mar 2009 09:25:54 -0700 Subject: [Javascript] Try and Catch Question Message-ID: <1a5ac85e$4f695c4c$5ce78217$@com> Usually with a Javascript exception, you'll be looking at the message rather than the exception type (since technically, everything is variant in JS anyway). ---------------------------------------- From: "Alexander Freiria" xandercoded at gmail.com I am a C# .NET developer. I know that there are different types of objects that are thrown... Given this, it is possible to check the type of object thrown and react in different ways... For the how that this is done in Javascript I am not too sure. An example of this would be nice. On Mon, Mar 2, 2009 at 8:51 AM, MEM wrote: > Ok... we have to have patience with me, sorry, here it goes: > > So you are saying that the (e) is there so we can identify what as being > thrown. Why? Because if we identify what as being thrown we can use that > identifier somehow, for example, > If "we want to ignore some errors but we want to respond to others". Is > this > assumption correct? > > The fact that we cannot have a catch() without something inside is because > we are not defining WHAT we want to catch, but that supposes that, with a > catch(), we can catch more than exceptions. Right? > But is that really important to distinguish what kind of catch are we > having > there? I mean, since the procedure is the same for no matter what is catch > by the catch function, why can't we have a simple catch(), for the cases > that we don't want to distinguish the exceptions? I'm sure someone have > thinking this before, and there is a reason why we cannot have catch() > alone. That's probably the main reason why I can't fully understand, in > some > cases, (because the other cases you have already told me) why oh why, we > need something inside the (). > > > Ps- I've really search on the net for this, but it seems like everybody > explains how to do the "try catch" thing, but they don't explain properly > what each part of the "try catch" really means. > > > Thanks a lot once again, > M?rcio > > > -----Original Message----- > From: javascript-bounces at lists.evolt.org > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of John Warner > Sent: segunda-feira, 2 de Mar?o de 2009 12:49 > To: 'JavaScript List' > Subject: Re: [Javascript] Try and Catch Question > > (e) allows your catch block to indentify the exception thrown. In some try > blocks more than one thing can go wrong, you might choose to ignore some > errors but want to respond to others. > > John Warner > > > > -----Original Message----- > > From: javascript-bounces at lists.evolt.org [mailto:javascript- > > bounces at lists.evolt.org] On Behalf Of MEM > > Sent: Monday, March 02, 2009 7:16 AM > > To: javascript at lists.evolt.org > > Subject: [Javascript] Try and Catch Question > > > > Hi all, this is my first post, (so if anything is not right in the way I > > post, please let me know). > > > > > > > > > > > > When we use a try catch statement like this: > > > > try { > > > > > > > > } catch (e) { > > > > > > > > } > > > > > > > > Why do we need the 'e' ? > > > > > > > > Well, I have seen also with 'err' etc, so I presume the point is to have > > only something that represents the name error. But, what for? I mean, > > normally in this kind of statements I never see that 'e' or 'err' being > used > > for nothing, I see no e="ups error" or something. So, what is that e > for? > > > > > > > > > > > > Thanks a lot, > > > > M?rcio From xandercoded at gmail.com Mon Mar 2 11:27:11 2009 From: xandercoded at gmail.com (Alexander Freiria) Date: Mon, 2 Mar 2009 12:27:11 -0500 Subject: [Javascript] Try and Catch Question In-Reply-To: <1a5ac85e$4f695c4c$5ce78217$@com> References: <1a5ac85e$4f695c4c$5ce78217$@com> Message-ID: Ah yes you are right... var foo = something On Mon, Mar 2, 2009 at 11:25 AM, Peter Brunone wrote: > Usually with a Javascript exception, you'll be looking at the message > rather than the exception type (since technically, everything is variant in > JS anyway). > > ---------------------------------------- > > From: "Alexander Freiria" xandercoded at gmail.com > > I am a C# .NET developer. I know that there are different types of objects > that are thrown... Given this, it is possible to check the type of object > thrown and react in different ways... For the how that this is done in > Javascript I am not too sure. An example of this would be nice. > > On Mon, Mar 2, 2009 at 8:51 AM, MEM wrote: > > > Ok... we have to have patience with me, sorry, here it goes: > > > > So you are saying that the (e) is there so we can identify what as being > > thrown. Why? Because if we identify what as being thrown we can use that > > identifier somehow, for example, > > If "we want to ignore some errors but we want to respond to others". Is > > this > > assumption correct? > > > > The fact that we cannot have a catch() without something inside is > because > > we are not defining WHAT we want to catch, but that supposes that, with a > > catch(), we can catch more than exceptions. Right? > > But is that really important to distinguish what kind of catch are we > > having > > there? I mean, since the procedure is the same for no matter what is > catch > > by the catch function, why can't we have a simple catch(), for the cases > > that we don't want to distinguish the exceptions? I'm sure someone have > > thinking this before, and there is a reason why we cannot have catch() > > alone. That's probably the main reason why I can't fully understand, in > > some > > cases, (because the other cases you have already told me) why oh why, we > > need something inside the (). > > > > > > Ps- I've really search on the net for this, but it seems like everybody > > explains how to do the "try catch" thing, but they don't explain properly > > what each part of the "try catch" really means. > > > > > > Thanks a lot once again, > > M?rcio > > > > > > -----Original Message----- > > From: javascript-bounces at lists.evolt.org > > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of John Warner > > Sent: segunda-feira, 2 de Mar?o de 2009 12:49 > > To: 'JavaScript List' > > Subject: Re: [Javascript] Try and Catch Question > > > > (e) allows your catch block to indentify the exception thrown. In some > try > > blocks more than one thing can go wrong, you might choose to ignore some > > errors but want to respond to others. > > > > John Warner > > > > > > > -----Original Message----- > > > From: javascript-bounces at lists.evolt.org [mailto:javascript- > > > bounces at lists.evolt.org] On Behalf Of MEM > > > Sent: Monday, March 02, 2009 7:16 AM > > > To: javascript at lists.evolt.org > > > Subject: [Javascript] Try and Catch Question > > > > > > Hi all, this is my first post, (so if anything is not right in the way > I > > > post, please let me know). > > > > > > > > > > > > > > > > > > When we use a try catch statement like this: > > > > > > try { > > > > > > > > > > > > } catch (e) { > > > > > > > > > > > > } > > > > > > > > > > > > Why do we need the 'e' ? > > > > > > > > > > > > Well, I have seen also with 'err' etc, so I presume the point is to > have > > > only something that represents the name error. But, what for? I mean, > > > normally in this kind of statements I never see that 'e' or 'err' being > > used > > > for nothing, I see no e="ups error" or something. So, what is that e > > for? > > > > > > > > > > > > > > > > > > Thanks a lot, > > > > > > M?rcio > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > From trojani2000 at hotmail.com Tue Mar 3 09:44:04 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Tue, 3 Mar 2009 15:44:04 +0000 Subject: [Javascript] Try and Catch Question In-Reply-To: <000101c99b30$a7fb9cb0$f7f2d610$@com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> Message-ID: Hello MEM, > Well, I have seen also with ?err? etc, so I presume the point is to have > only something that represents the name error. But, what for? I mean, > normally in this kind of statements I never see that ?e? or ?err? being used > for nothing, I see no e=?ups error? or something. So, what is that e for? The "catch(whatever)" is obviously a function-call that depends on the coder input for it to become useful. If you catch the error, you are certainly aiming to get the cause, and since there was no way of knowing the argument-name of this function for all the browsers that wrote it independently, it was wisely decided to let this arg be named by the coder so you can extract at least some poor laconic info about the expected error using your own bite. Anyway the catch() function will fail to execute if this arg is missing. It will most probably yield "null", so the error will slip off the catch and the suppression will fail. > Why do we need the ?e? ? Aside the fact that omitting "e" will cause the error capture to fail suppress the expected error, we need it to watch for our runtime errors like in: try { thisUndeclaredFunction() } catch(thatError){ alert(thatError.message) } [As you can see we're not using "e" or "err"] In this example our alert(thatError.message) request will report: "Object expected" or if we alert(thatError.name) we'll get "typeError" meaning: error in expected variable type has occurred, which is caused by "thisUndeclaredFunction()" name variable call. It is completely unreasonable to call "document.getElementById()" if you are not aiming to really catch some particular element in your var. Therefore using the catch() method to simply suppress some error you don't care to know what, might well be called a misuse, since suppressing errors anonymously can be achieved globally by simply returning "true" for the "onerror" event. Regards. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > From: talofo at gmail.com > To: javascript at lists.evolt.org > Date: Mon, 2 Mar 2009 12:16:02 +0000 > Subject: [Javascript] Try and Catch Question > > Hi all, this is my first post, (so if anything is not right in the way I > post, please let me know). > > > > > > When we use a try catch statement like this: > > try { > > > > } catch (e) { > > > > } > > > > Why do we need the ?e? ? > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > only something that represents the name error. But, what for? I mean, > normally in this kind of statements I never see that ?e? or ?err? being used > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > > > Thanks a lot, > > M?rcio > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 From talofo at gmail.com Tue Mar 3 10:40:14 2009 From: talofo at gmail.com (MEM) Date: Tue, 3 Mar 2009 16:40:14 -0000 Subject: [Javascript] Try and Catch Question In-Reply-To: References: <000101c99b30$a7fb9cb0$f7f2d610$@com> Message-ID: <000901c99c1e$baf6faf0$30e4f0d0$@com> THANK A LOT for all the replys. :) I'm more then glad! Here I go digging deep into javascript again! :) Thanks a million, really. Hope I can count on the mailing list for more newbie questions, because I really want to properly LEARN javascript. And one day maybe I will be on your side. Regards, M?rcio -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Troy III Ajnej Sent: ter?a-feira, 3 de Mar?o de 2009 15:44 To: javascript at lists.evolt.org Subject: Re: [Javascript] Try and Catch Question Hello MEM, > Well, I have seen also with ?err? etc, so I presume the point is to have > only something that represents the name error. But, what for? I mean, > normally in this kind of statements I never see that ?e? or ?err? being used > for nothing, I see no e=?ups error? or something. So, what is that e for? The "catch(whatever)" is obviously a function-call that depends on the coder input for it to become useful. If you catch the error, you are certainly aiming to get the cause, and since there was no way of knowing the argument-name of this function for all the browsers that wrote it independently, it was wisely decided to let this arg be named by the coder so you can extract at least some poor laconic info about the expected error using your own bite. Anyway the catch() function will fail to execute if this arg is missing. It will most probably yield "null", so the error will slip off the catch and the suppression will fail. > Why do we need the ?e? ? Aside the fact that omitting "e" will cause the error capture to fail suppress the expected error, we need it to watch for our runtime errors like in: try { thisUndeclaredFunction() } catch(thatError){ alert(thatError.message) } [As you can see we're not using "e" or "err"] In this example our alert(thatError.message) request will report: "Object expected" or if we alert(thatError.name) we'll get "typeError" meaning: error in expected variable type has occurred, which is caused by "thisUndeclaredFunction()" name variable call. It is completely unreasonable to call "document.getElementById()" if you are not aiming to really catch some particular element in your var. Therefore using the catch() method to simply suppress some error you don't care to know what, might well be called a misuse, since suppressing errors anonymously can be achieved globally by simply returning "true" for the "onerror" event. Regards. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > From: talofo at gmail.com > To: javascript at lists.evolt.org > Date: Mon, 2 Mar 2009 12:16:02 +0000 > Subject: [Javascript] Try and Catch Question > > Hi all, this is my first post, (so if anything is not right in the way I > post, please let me know). > > > > > > When we use a try catch statement like this: > > try { > > > > } catch (e) { > > > > } > > > > Why do we need the ?e? ? > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > only something that represents the name error. But, what for? I mean, > normally in this kind of statements I never see that ?e? or ?err? being used > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > > > Thanks a lot, > > M?rcio > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 _______________________________________________ Javascript mailing list Javascript at lists.evolt.org http://lists.evolt.org/mailman/listinfo/javascript From blmatthews at gmail.com Tue Mar 3 14:52:24 2009 From: blmatthews at gmail.com (Brian L. Matthews) Date: Tue, 03 Mar 2009 12:52:24 -0800 Subject: [Javascript] Try and Catch Question In-Reply-To: References: <000101c99b30$a7fb9cb0$f7f2d610$@com> Message-ID: <49AD9888.2000001@gmail.com> > > > The "catch(whatever)" is obviously a function-call > Uh, no. catch specifies where the program flow should go when throw is executed in the block preceding the catch. The whatever is just a variable that gets assigned the value that was thrown. It's often e or err for obvious reasons, but there's nothing special about either of those names. Brian From xandercoded at gmail.com Tue Mar 3 14:58:33 2009 From: xandercoded at gmail.com (Alexander Freiria) Date: Tue, 3 Mar 2009 15:58:33 -0500 Subject: [Javascript] Try and Catch Question In-Reply-To: <49AD9888.2000001@gmail.com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> Message-ID: I second that. That is what the function of the catch is for... On Tue, Mar 3, 2009 at 3:52 PM, Brian L. Matthews wrote: > > > > > > The "catch(whatever)" is obviously a function-call > > > > Uh, no. catch specifies where the program flow should go when throw is > executed in the block preceding the catch. The whatever is just a > variable that gets assigned the value that was thrown. It's often e or > err for obvious reasons, but there's nothing special about either of > those names. > > Brian > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > From scott at randomchaos.com Tue Mar 3 15:20:46 2009 From: scott at randomchaos.com (Scott Reynen) Date: Tue, 3 Mar 2009 14:20:46 -0700 Subject: [Javascript] Try and Catch Question In-Reply-To: References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> Message-ID: On [Mar 3], at [ Mar 3] 1:58 , Alexander Freiria wrote: >>> The "catch(whatever)" is obviously a function-call >> >> >> Uh, no. catch specifies where the program flow should go when throw >> is >> executed in the block preceding the catch. > > I second that. That is what the function of the catch is for... To be a bit pedantic, catch is not actually a function, despite having similar syntax. You can assign a function to a variable, for example, but you'll get a syntax error if you try to assign catch to a variable. Peace, Scott From xandercoded at gmail.com Tue Mar 3 15:50:20 2009 From: xandercoded at gmail.com (Alexander Freiria) Date: Tue, 3 Mar 2009 16:50:20 -0500 Subject: [Javascript] Try and Catch Question In-Reply-To: References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> Message-ID: I did not say that catch was a function, it (functions) similar to a function receiving a variable/object and assigning the local variable, in this case "whatever" to the incoming "thrown" variable/object... On Tue, Mar 3, 2009 at 4:20 PM, Scott Reynen wrote: > On [Mar 3], at [ Mar 3] 1:58 , Alexander Freiria wrote: > > >>> The "catch(whatever)" is obviously a function-call > >> > >> > >> Uh, no. catch specifies where the program flow should go when throw > >> is > >> executed in the block preceding the catch. > > > > > I second that. That is what the function of the catch is for... > > > To be a bit pedantic, catch is not actually a function, despite having > similar syntax. You can assign a function to a variable, for example, > but you'll get a syntax error if you try to assign catch to a variable. > > Peace, > Scott > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > From shashankan.10 at gmail.com Wed Mar 4 00:22:50 2009 From: shashankan.10 at gmail.com (shashanka n) Date: Wed, 4 Mar 2009 11:52:50 +0530 Subject: [Javascript] Javascript Digest, Vol 19, Issue 2 In-Reply-To: References: Message-ID: On Tue, Mar 3, 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. Re: Try and Catch Question (Troy III Ajnej) > 2. Re: Try and Catch Question (MEM) > > > ---------- Forwarded message ---------- > From: Troy III Ajnej > To: > Date: Tue, 3 Mar 2009 15:44:04 +0000 > Subject: Re: [Javascript] Try and Catch Question > > Hello MEM, > > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > > > only something that represents the name error. But, what for? I mean, > > > normally in this kind of statements I never see that ?e? or ?err? being > used > > > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > The "catch(whatever)" is obviously a function-call that depends on > > the coder input for it to become useful. If you catch the error, you > > are certainly aiming to get the cause, and since there was no way > > of knowing the argument-name of this function for all the browsers > > that wrote it independently, it was wisely decided to let this arg > > be named by the coder so you can extract at least some poor laconic > > info about the expected error using your own bite. > > Anyway the catch() function will fail to execute if this arg is missing. > > It will most probably yield "null", so the error will slip off the catch > and > > the suppression will fail. > > > > > Why do we need the ?e? ? > > Aside the fact that omitting "e" will cause the error capture to fail > suppress > > the expected error, we need it to watch for our runtime errors like in: > > > > try { > > thisUndeclaredFunction() > > } > > > > catch(thatError){ > > alert(thatError.message) > > } > > > > [As you can see we're not using "e" or "err"] > > > > In this example our alert(thatError.message) request will report: > > "Object expected" or if we alert(thatError.name) we'll get "typeError" > > meaning: error in expected variable type has occurred, which is caused > > by "thisUndeclaredFunction()" name variable call. > > > > It is completely unreasonable to call "document.getElementById()" > > if you are not aiming to really catch some particular element in your var. > > Therefore using the catch() method to simply suppress some error > > you don't care to know what, might well be called a misuse, since > > suppressing errors anonymously can be achieved globally by simply returning > > "true" for the "onerror" event. > > > > Regards. > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Troy III > progressive art enterprise > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > From: talofo at gmail.com > > To: javascript at lists.evolt.org > > Date: Mon, 2 Mar 2009 12:16:02 +0000 > > Subject: [Javascript] Try and Catch Question > > > > Hi all, this is my first post, (so if anything is not right in the way I > > post, please let me know). > > > > > > > > > > > > When we use a try catch statement like this: > > > > try { > > > > > > > > } catch (e) { > > > > > > > > } > > > > > > > > Why do we need the ?e? ? > > > > > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > > only something that represents the name error. But, what for? I mean, > > normally in this kind of statements I never see that ?e? or ?err? being > used > > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > > > > > > > > > Thanks a lot, > > > > M?rcio > > > > _______________________________________________ > > Javascript mailing list > > Javascript at lists.evolt.org > > http://lists.evolt.org/mailman/listinfo/javascript > > _________________________________________________________________ > Windows Live? Groups: Create an online spot for your favorite groups to > meet. > http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 > > > ---------- Forwarded message ---------- > From: "MEM" > To: "'JavaScript List'" > Date: Tue, 3 Mar 2009 16:40:14 -0000 > Subject: Re: [Javascript] Try and Catch Question > THANK A LOT for all the replys. :) I'm more then glad! > > Here I go digging deep into javascript again! :) > > Thanks a million, really. Hope I can count on the mailing list for more > newbie questions, because I really want to properly LEARN javascript. > And one day maybe I will be on your side. > > Regards, > M?rcio > > > -----Original Message----- > From: javascript-bounces at lists.evolt.org > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Troy III Ajnej > Sent: ter?a-feira, 3 de Mar?o de 2009 15:44 > To: javascript at lists.evolt.org > Subject: Re: [Javascript] Try and Catch Question > > > Hello MEM, > > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > > > only something that represents the name error. But, what for? I mean, > > > normally in this kind of statements I never see that ?e? or ?err? being > used > > > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > The "catch(whatever)" is obviously a function-call that depends on > > the coder input for it to become useful. If you catch the error, you > > are certainly aiming to get the cause, and since there was no way > > of knowing the argument-name of this function for all the browsers > > that wrote it independently, it was wisely decided to let this arg > > be named by the coder so you can extract at least some poor laconic > > info about the expected error using your own bite. > > Anyway the catch() function will fail to execute if this arg is missing. > > It will most probably yield "null", so the error will slip off the catch > and > > the suppression will fail. > > > > > Why do we need the ?e? ? > > Aside the fact that omitting "e" will cause the error capture to fail > suppress > > the expected error, we need it to watch for our runtime errors like in: > > > > try { > > thisUndeclaredFunction() > > } > > > > catch(thatError){ > > alert(thatError.message) > > } > > > > [As you can see we're not using "e" or "err"] > > > > In this example our alert(thatError.message) request will report: > > "Object expected" or if we alert(thatError.name) we'll get "typeError" > > meaning: error in expected variable type has occurred, which is caused > > by "thisUndeclaredFunction()" name variable call. > > > > It is completely unreasonable to call "document.getElementById()" > > if you are not aiming to really catch some particular element in your var. > > Therefore using the catch() method to simply suppress some error > > you don't care to know what, might well be called a misuse, since > > suppressing errors anonymously can be achieved globally by simply returning > > "true" for the "onerror" event. > > > > Regards. > > > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Troy III > progressive art enterprise > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > From: talofo at gmail.com > > To: javascript at lists.evolt.org > > Date: Mon, 2 Mar 2009 12:16:02 +0000 > > Subject: [Javascript] Try and Catch Question > > > > Hi all, this is my first post, (so if anything is not right in the way I > > post, please let me know). > > > > > > > > > > > > When we use a try catch statement like this: > > > > try { > > > > > > > > } catch (e) { > > > > > > > > } > > > > > > > > Why do we need the ?e? ? > > > > > > > > Well, I have seen also with ?err? etc, so I presume the point is to have > > only something that represents the name error. But, what for? I mean, > > normally in this kind of statements I never see that ?e? or ?err? being > used > > for nothing, I see no e=?ups error? or something. So, what is that e for? > > > > > > > > > > > > Thanks a lot, > > > > M?rcio > > > > _______________________________________________ > > Javascript mailing list > > Javascript at lists.evolt.org > > http://lists.evolt.org/mailman/listinfo/javascript > > _________________________________________________________________ > Windows Live? Groups: Create an online spot for your favorite groups to > meet. > http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 > _______________________________________________ > 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 > Um, though this might seem off topic, i would like to point out that the try catch statements should not be used in a very generic way. Such as this try{ //MAJOR chunk of your code } catch(err) { //Do something to rectify this... } I would recommend this rather be used for small chunks of your code rather than put a majority of your code in the try section... -- - Warm regards Shashanka N From trojani2000 at hotmail.com Sun Mar 8 06:29:06 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Sun, 8 Mar 2009 11:29:06 +0000 Subject: [Javascript] Try and Catch Question In-Reply-To: <49AD9888.2000001@gmail.com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> Message-ID: Everything. Absolutely everything that requires paranethesis is a function. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Date: Tue, 3 Mar 2009 12:52:24 -0800 > From: blmatthews at gmail.com > To: javascript at lists.evolt.org > Subject: Re: [Javascript] Try and Catch Question > > > > > > > The "catch(whatever)" is obviously a function-call > > > > Uh, no. catch specifies where the program flow should go when throw is > executed in the block preceding the catch. The whatever is just a > variable that gets assigned the value that was thrown. It's often e or > err for obvious reasons, but there's nothing special about either of > those names. > > Brian > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live? Contacts: Organize your contact list. http://windowslive.com/connect/post/marcusatmicrosoft.spaces.live.com-Blog-cns!503D1D86EBB2B53C!2285.entry?ocid=TXT_TAGLM_WL_UGC_Contacts_032009 From bhawkeslewis at googlemail.com Sun Mar 8 09:25:39 2009 From: bhawkeslewis at googlemail.com (Benjamin Hawkes-Lewis) Date: Sun, 08 Mar 2009 14:25:39 +0000 Subject: [Javascript] Try and Catch Question In-Reply-To: References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> Message-ID: <49B3D563.30001@googlemail.com> On 8/3/09 11:29, Troy III Ajnej wrote: > Absolutely everything that requires paranethesis is a function. That's not true according to the ECMAScript specification. "try" is a statement. "catch" is a clause in that statement. All "functions" in ECMAScript are objects. "catch" is not an object. See especially ECMA 262 sections 8.6.2 and 12.14: http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf -- Benjamin Hawkes-Lewis From trojani2000 at hotmail.com Tue Mar 10 09:28:14 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Tue, 10 Mar 2009 14:28:14 +0000 Subject: [Javascript] Try and Catch Question In-Reply-To: <49B3D563.30001@googlemail.com> References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> <49B3D563.30001@googlemail.com> Message-ID: > Benjamin Hawkes-Lewis > From: bhawkeslewis at googlemail.com Hello Benjamin, thanks for your reply. > > On 8/3/09 11:29, Troy III Ajnej wrote: > > Absolutely everything that requires paranethesis is a function. > > That's not true according to the ECMAScript specification. > ECMAScript is not a brower Script. In addition:The try\catch()\finally algo is still, not a part of ECMA. (Although the "try" keyword was listed as reserved in ECMA to) > > "try" is a statement. "catch" is a clause in that statement. > Naturally. > > All "functions" in ECMAScript are objects. "catch" is not an object. > False... Every object is not a function and not all (buillt in) functions may be objects. Paracoxically, event the Object object, is a pure function! Or may I say: a Function function or a function Object, or... alert(Object); .::the alert content::. function Object() { [native code] } As you can see, Objects are functions itself. Even the Function is a function. alert(Function); will result in: function Function(){[native code]} (are we entering into some kind of a "name:notion" loop?) "Math" is an object, .max(); .min() is not! These are functions: alert(Math.max); alert(Math.min);//etc... The "document.getElementById()" is most probably considered everything else but function. Well, function it is. alert(document.getElementById) . . . Regards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _________________________________________________________________ Hotmail? is up to 70% faster. Now good news travels really fast. http://windowslive.com/online/hotmail?ocid=TXT_TAGLM_WL_HM_70faster_032009 From scott at randomchaos.com Tue Mar 10 10:35:52 2009 From: scott at randomchaos.com (Scott Reynen) Date: Tue, 10 Mar 2009 09:35:52 -0600 Subject: [Javascript] Try and Catch Question In-Reply-To: References: <000101c99b30$a7fb9cb0$f7f2d610$@com> <49AD9888.2000001@gmail.com> <49B3D563.30001@googlemail.com> Message-ID: <91B8DD7D-0000-4A83-97C9-FA336BEF1EC0@randomchaos.com> On [Mar 10], at [ Mar 10] 8:28 , Troy III Ajnej wrote: > ECMAScript is not a brower Script. There's certainly a difference between spec and implementation, but you seem to be wrong in both contexts, so I don't see how that's relevant. Can you point to a single browser that treats catch like other functions? For example, do any browsers return "function" for typeof catch? Or allow you to assign catch to a variable? Or really do anything resembling a function beyond taking parameters? Do you also contend if, while, and for are functions? > In addition:The try\catch()\finally algo is still, not a part of ECMA. It's in the ECMAScript spec, right where Benjamin pointed to it. >> All "functions" in ECMAScript are objects. "catch" is not an object. > > False... If you read the ECMAScript spec, you'll find this: > 10.1.1 Function Objects > There are two types of Function objects: > ? Program functions are defined in source text by a > FunctionDeclaration or created dynamically either > by using a FunctionExpression or by using the built-in Function > object as a constructor. > ? Internal functions are built-in objects of the language, such as > parseInt and Math.exp. An > implementation may also provide implementation-dependent internal > functions that are not described > in this specification. These functions do not contain executable > code defined by the ECMAScript > grammar, so they are excluded from this discussion of execution > contexts. That covers all of the different functions you mentioned, and they're all objects. > Every object is not a function No one said they were. > and not all (buillt in) functions may be > > objects. Can you point to anything beyond your own words supporting your arguments? Peace, Scott From javascript at webdesignofficina.com Tue Mar 10 10:35:56 2009 From: javascript at webdesignofficina.com (javascript at webdesignofficina.com) Date: Tue, 10 Mar 2009 16:35:56 +0100 Subject: [Javascript] Selecting certain areas of text in a string Message-ID: Hi there, Currently trying to change the url of an embedded element in a page... My problem is that many other parameters are passed along the url of the object, in the src property: src="../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/ somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10" I'd like to only rewrite this part: file=http://www.somesite.com/ video/somevideo.flv Rest of the parameters should remain untouched... I know I should use String.replace, something like: var str="somevideo.flv!"; document.write(str.replace(/somevideo.flv/,"othervideo.flv")); But I have absolutely no idea on how target this piece of text only in the whole src="...", starting from ending file path, from / to .flv Any help would be greatly appreciated. Thank you. Best regards, Guillaume Stricher From bader at tcbader.com Tue Mar 10 10:40:56 2009 From: bader at tcbader.com (Terry Bader) Date: Tue, 10 Mar 2009 08:40:56 -0700 Subject: [Javascript] Try and Catch Question Message-ID: <3675fcc7$72d11591$176cdb3$@com> Take the fight off list. Thanks... ~Terry ---------------------------------------- From: "Scott Reynen" Sent: Tuesday, March 10, 2009 11:36 AM To: "JavaScript List" Subject: Re: [Javascript] Try and Catch Question On [Mar 10], at [ Mar 10] 8:28 , Troy III Ajnej wrote: > ECMAScript is not a brower Script. There's certainly a difference between spec and implementation, but you seem to be wrong in both contexts, so I don't see how that's relevant. Can you point to a single browser that treats catch like other functions? For example, do any browsers return "function" for typeof catch? Or allow you to assign catch to a variable? Or really do anything resembling a function beyond taking parameters? Do you also contend if, while, and for are functions? > In addition:The try\catch()\finally algo is still, not a part of ECMA. It's in the ECMAScript spec, right where Benjamin pointed to it. >> All "functions" in ECMAScript are objects. "catch" is not an object. > > False... If you read the ECMAScript spec, you'll find this: > 10.1.1 Function Objects > There are two types of Function objects: > . Program functions are defined in source text by a > FunctionDeclaration or created dynamically either > by using a FunctionExpression or by using the built-in Function > object as a constructor. > . Internal functions are built-in objects of the language, such as > parseInt and Math.exp. An > implementation may also provide implementation-dependent internal > functions that are not described > in this specification. These functions do not contain executable > code defined by the ECMAScript > grammar, so they are excluded from this discussion of execution > contexts. That covers all of the different functions you mentioned, and they're all objects. > Every object is not a function No one said they were. > and not all (buillt in) functions may be > > objects. Can you point to anything beyond your own words supporting your arguments? Peace, Scott _______________________________________________ Javascript mailing list Javascript at lists.evolt.org http://lists.evolt.org/mailman/listinfo/javascript From nick at nickfitz.co.uk Tue Mar 10 12:30:19 2009 From: nick at nickfitz.co.uk (Nick Fitzsimons) Date: Tue, 10 Mar 2009 17:30:19 -0000 (GMT) Subject: [Javascript] Selecting certain areas of text in a string In-Reply-To: References: Message-ID: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> Apologies if this gets posted twice - my webmail is playing up :-( Assuming your element has the ID "movie" then var movie = document.getElementById("movie"); movie.src = movie.src.replace(/somevideo.flv/, "othervideo.flv"); should do the trick. Regards, Nick. On Tue, March 10, 2009 3:35 pm, javascript at webdesignofficina.com wrote: > > Hi there, > > Currently trying to change the url of an embedded element in a page... > My problem is that many other parameters are passed along the url of > the object, in the src property: > > src="../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/ > somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10" > > I'd like to only rewrite this part: file=http://www.somesite.com/ > video/somevideo.flv > Rest of the parameters should remain untouched... > > I know I should use String.replace, something like: > > var str="somevideo.flv!"; > document.write(str.replace(/somevideo.flv/,"othervideo.flv")); > > But I have absolutely no idea on how target this piece of text only in the > whole src="...", starting from ending file path, from / to .flv > > Any help would be greatly appreciated. > > Thank you. > > Best regards, > > Guillaume Stricher > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > -- Nick Fitzsimons http://www.nickfitz.co.uk/ From Mark.Rees at astrazeneca.com Wed Mar 11 05:20:30 2009 From: Mark.Rees at astrazeneca.com (Rees, Mark) Date: Wed, 11 Mar 2009 10:20:30 -0000 Subject: [Javascript] Selecting certain areas of text in a string In-Reply-To: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> Message-ID: If you need to match anything more complex than a single movie name e.g. if you need to match somemovie1.flv, somemovie2.flv and so on, you could consider a regular expression. Here's a few links to get started A general introduction http://www.regular-expressions.info/tutorial.html JavaScript's implementation https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/RegExp Firefox has a good add-on called "regular expressions tester" which you can use to fine tune your expression. You can use it as the first parameter in the string.replace command. You will find an explanation and some examples here https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Global_Objects/String/Replace -------------------------------------------------------------------------- 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 Nick Fitzsimons Sent: 10 March 2009 17:30 To: JavaScript List Subject: Re: [Javascript] Selecting certain areas of text in a string Apologies if this gets posted twice - my webmail is playing up :-( Assuming your element has the ID "movie" then var movie = document.getElementById("movie"); movie.src = movie.src.replace(/somevideo.flv/, "othervideo.flv"); should do the trick. Regards, Nick. On Tue, March 10, 2009 3:35 pm, javascript at webdesignofficina.com wrote: > > Hi there, > > Currently trying to change the url of an embedded element in a page... > My problem is that many other parameters are passed along the url of > the object, in the src property: > > src="../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/ > somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10" > > I'd like to only rewrite this part: file=http://www.somesite.com/ > video/somevideo.flv > Rest of the parameters should remain untouched... > > I know I should use String.replace, something like: > > var str="somevideo.flv!"; > document.write(str.replace(/somevideo.flv/,"othervideo.flv")); > > But I have absolutely no idea on how target this piece of text only in the > whole src="...", starting from ending file path, from / to .flv > > Any help would be greatly appreciated. > > Thank you. > > Best regards, > > Guillaume Stricher From talofo at gmail.com Wed Mar 11 09:57:24 2009 From: talofo at gmail.com (MEM) Date: Wed, 11 Mar 2009 14:57:24 -0000 Subject: [Javascript] Newbie - Making a Inline validation using js DOM and CSS In-Reply-To: References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> Message-ID: <001301c9a259$b378fe90$1a6afbb0$@com> Hi all, Ok. I have a CSS class to hide divs with the 'display' property. The point is: when the user changes the focus, it displays the "error_div" OF THAT ASSOCIATED FIELD. I have several problems that I can't see to find a solution: 1) Does not work with IE ! (onsumbit seams having no effect on IE, since no matter if the onsubmit is true or false, the form gets submitted!) What may be the problem? 2) When the onblur() function is executed the function returns the error message, if a field is empty. Good. But it doesn't make the relation between the onblur() of a specific textfield, and that textfield error div message. I mean: If we don't type the "name" and the "age" field for example, and you click with your mouse over the age field and then, without write anything inside, you take your mouse away, you will not receive the error: "please insert your age" but, instead, you will receive "please insert your name", only because the name comes first. 3) When the user touches submit, it shows only one error message at the time. To see the next error, the user needs to hit submit again. What is the technique to search, for displaying all errors at once? I understand that my error is not really related with javascript, is more related with newbie programming incapacities. But can I please have a light about how to solve this issues? Here is the code: &&& THE FUNCTION function validar(nome,idade,email) { var nome = document.getElementById("nome").value; var idade = document.getElementById("idade").value; var email = document.getElementById("email").value; if (nome == "") { document.getElementById("erro_nome").style.display = "inline"; document.getElementById("nome").select(); document.getElementById("nome").focus(); return false; } else if(idade == "") { document.getElementById("erro_idade").style.display = "inline;" document.getElementById("idade").select(); document.getElementById("idade").focus(); return false; } else if(email == "") { document.getElementById("erro_email").style.display = "inline;" document.getElementById("email").select(); document.getElementById("email").focus(); return false; } return true; } THE FORM:
Regards, M?rcio From talofo at gmail.com Wed Mar 11 10:25:20 2009 From: talofo at gmail.com (MEM) Date: Wed, 11 Mar 2009 15:25:20 -0000 Subject: [Javascript] Newbie - Making a Inline validation using js DOM and CSS References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> Message-ID: <001a01c9a25d$98562350$c90269f0$@com> Here I am replying to myself. Ok. The issue number 3) is solved. It seems that, when we use return the function returns that value (amazing my conclusions! :s) Also, if I use "else if" that doesn?t help. Case it will only execute the "else if" if the first "if" doesn't apply. (another amazing conclusion! :s) I've change the code like the following: function validar(nome,idade,email) { var nome = document.getElementById("nome").value; var idade = document.getElementById("idade").value; var email = document.getElementById("email").value; var valido=true; //this is my Boolean flag. if (nome == "") { document.getElementById("erro_nome").style.display = "inline"; document.getElementById("nome").select(); document.getElementById("nome").focus(); valido=false; } else if(idade == "") { document.getElementById("erro_idade").style.display = "inline;" document.getElementById("idade").select(); document.getElementById("idade").focus(); valido=false; } else if(email == "") { document.getElementById("erro_email").style.display = "inline;" document.getElementById("email").select(); document.getElementById("email").focus(); valido=false; } return valido; } Now the issue 3) is solved. I still need help on the other two. Regards once again, M?rcio -----Original Message----- From: MEM [mailto:talofo at gmail.com] Sent: quarta-feira, 11 de Mar?o de 2009 14:57 To: 'JavaScript List' Subject: Newbie - Making a Inline validation using js DOM and CSS Hi all, Ok. I have a CSS class to hide divs with the 'display' property. The point is: when the user changes the focus, it displays the "error_div" OF THAT ASSOCIATED FIELD. I have several problems that I can't see to find a solution: 1) Does not work with IE ! (onsumbit seams having no effect on IE, since no matter if the onsubmit is true or false, the form gets submitted!) What may be the problem? 2) When the onblur() function is executed the function returns the error message, if a field is empty. Good. But it doesn't make the relation between the onblur() of a specific textfield, and that textfield error div message. I mean: If we don't type the "name" and the "age" field for example, and you click with your mouse over the age field and then, without write anything inside, you take your mouse away, you will not receive the error: "please insert your age" but, instead, you will receive "please insert your name", only because the name comes first. 3) When the user touches submit, it shows only one error message at the time. To see the next error, the user needs to hit submit again. What is the technique to search, for displaying all errors at once? I understand that my error is not really related with javascript, is more related with newbie programming incapacities. But can I please have a light about how to solve this issues? Here is the code: &&& THE FUNCTION function validar(nome,idade,email) { var nome = document.getElementById("nome").value; var idade = document.getElementById("idade").value; var email = document.getElementById("email").value; if (nome == "") { document.getElementById("erro_nome").style.display = "inline"; document.getElementById("nome").select(); document.getElementById("nome").focus(); return false; } else if(idade == "") { document.getElementById("erro_idade").style.display = "inline;" document.getElementById("idade").select(); document.getElementById("idade").focus(); return false; } else if(email == "") { document.getElementById("erro_email").style.display = "inline;" document.getElementById("email").select(); document.getElementById("email").focus(); return false; } return true; } THE FORM:
Regards, M?rcio From nick at nickfitz.co.uk Wed Mar 11 10:31:35 2009 From: nick at nickfitz.co.uk (Nick Fitzsimons) Date: Wed, 11 Mar 2009 15:31:35 -0000 (GMT) Subject: [Javascript] Newbie - Making a Inline validation using js DOM and CSS In-Reply-To: <001301c9a259$b378fe90$1a6afbb0$@com> References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> Message-ID: <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> Hi, In your error function you are returning false when a field is empty; therefore, if the name field is blank, it returns false and never goes on to check the other fields. Try breaking it apart into smaller functions to see the flow more clearly; try this: function validateField(fieldId, errorId) { var field = document.getElementById(fieldId); var value = field.value; if (value == "") { document.getElementById("errorId").style.display = "inline"; field.focus(); return false; } else { document.getElementById("errorId").style.display = "none"; return true; } } function validar() { return validateField("nome", "erro_nome") && validateField("idade", "erro_idade") && validateField("email", "erro_email"); } Then change your field HTML to just check the field that's blurring: (...do the same for the other two fields). There are a few other things you will probably have to do to get the code working reliably (for example, if somebody just types a space the check for "" will fail - Google for "javascript trim" to see how to deal with this) but the above should get you started. (Note: I haven't tested the above, so keep an eye out for any typing mistakes I've made :-) Regards, Nick. On Wed, March 11, 2009 2:57 pm, MEM wrote: > Hi all, > > Ok. I have a CSS class to hide divs with the 'display' property. > > The point is: > when the user changes the focus, it displays the "error_div" OF THAT > ASSOCIATED FIELD. > > I have several problems that I can't see to find a solution: > 1) Does not work with IE ! (onsumbit seams having no effect on IE, since > no > matter if the onsubmit is true or false, the form gets submitted!) What > may > be the problem? > > 2) When the onblur() function is executed the function returns the error > message, if a field is empty. Good. But it doesn't make the relation > between > the onblur() of a specific textfield, and that textfield error div > message. > I mean: If we don't type the "name" and the "age" field for example, and > you > click with your mouse over the age field and then, without write anything > inside, you take your mouse away, you will not receive the error: "please > insert your age" but, instead, you will receive "please insert your name", > only because the name comes first. > > 3) When the user touches submit, it shows only one error message at the > time. To see the next error, the user needs to hit submit again. What is > the > technique to search, for displaying all errors at once? > > > I understand that my error is not really related with javascript, is more > related with newbie programming incapacities. But can I please have a > light > about how to solve this issues? > > Here is the code: > > > &&& THE FUNCTION > > function validar(nome,idade,email) { > > var nome = document.getElementById("nome").value; > var idade = document.getElementById("idade").value; > var email = document.getElementById("email").value; > > if (nome == "") { > > > document.getElementById("erro_nome").style.display = "inline"; > document.getElementById("nome").select(); > document.getElementById("nome").focus(); > > return false; > > } > > > else if(idade == "") { > > > document.getElementById("erro_idade").style.display = "inline;" > document.getElementById("idade").select(); > document.getElementById("idade").focus(); > > > return false; > > } > > > else if(email == "") { > > > document.getElementById("erro_email").style.display = "inline;" > document.getElementById("email").select(); > document.getElementById("email").focus(); > > return false; > } > > > return true; > > > } > > > > THE FORM: > >
name="inserir_dados" onsubmit="return validar(nome,idade,email);"> > > > > > > > >
> > > > > > Regards, > M?rcio > > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript > -- Nick Fitzsimons http://www.nickfitz.co.uk/ From talofo at gmail.com Wed Mar 11 11:21:03 2009 From: talofo at gmail.com (MEM) Date: Wed, 11 Mar 2009 16:21:03 -0000 Subject: [Javascript] Newbie - Making a Inline validation using js DOM and CSS In-Reply-To: <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> Message-ID: <001b01c9a265$611ee0e0$235ca2a0$@com> Thanks a lot, Before actually read your reply, I have done the following code: function validar(nome,idade,email) { var nome = document.getElementById("nome").value; var idade = document.getElementById("idade").value; var email = document.getElementById("email").value; var valido=true; if (nome == "") { document.getElementById("erro_nome").style.display = "inline"; document.getElementById("nome").select(); document.getElementById("nome").focus(); valido = false; } else { document.getElementById("erro_nome").style.display = "none;" } if (idade == "") { document.getElementById("erro_idade").style.display = "inline;" document.getElementById("idade").select(); document.getElementById("idade").focus(); valido = false; } else { document.getElementById("erro_idade").style.display = "none;" } if(email == "") { document.getElementById("erro_email").style.display = "inline;" document.getElementById("email").select(); document.getElementById("email").focus(); valido = false; } else { document.getElementById("erro_email").style.display = "none;" } return valido; } But I get a loop when it happens. And I'm getting the browser to stop responding. (yupi, I can create virus! Even if I can't validate a form!). The weird about this is that, if I remove the email part of the code, and I stay with only two fields, he validates as expected in Aptana (the IDE I'm using) internal firefox browser). But it does not behave properly on browser direct testing. Why I'm I getting this cross-same browser inconsistencies? Before, I go to your code, I'd like to stay with mine, since, and even if it's less elegant, newbie etc... I'm starting to learn what I do where according to this trial / error method. ;) Can I please have some feedback again about, Why I'm I getting a loop. The links are here: This one is the "virus" one. He don't stop the loop. And the Firefox seams to hang up. http://ludmila.uuuq.com/teste_php_pagina_v4.html The two fields form that work in Aptana internal firefox browser but not on a real browser test, is here: http://ludmila.uuuq.com/teste_php_pagina_v5.html Regards once again, M?rcio PS TO ALL: If you believe that this cannot be accomplish, by any means, using something similar to this code, please, let me know so I can adopt Nick code and start understanding what it does. -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Nick Fitzsimons Sent: quarta-feira, 11 de Mar?o de 2009 15:32 To: JavaScript List Subject: Re: [Javascript] Newbie - Making a Inline validation using js DOM and CSS Hi, In your error function you are returning false when a field is empty; therefore, if the name field is blank, it returns false and never goes on to check the other fields. Try breaking it apart into smaller functions to see the flow more clearly; try this: function validateField(fieldId, errorId) { var field = document.getElementById(fieldId); var value = field.value; if (value == "") { document.getElementById("errorId").style.display = "inline"; field.focus(); return false; } else { document.getElementById("errorId").style.display = "none"; return true; } } function validar() { return validateField("nome", "erro_nome") && validateField("idade", "erro_idade") && validateField("email", "erro_email"); } Then change your field HTML to just check the field that's blurring: (...do the same for the other two fields). There are a few other things you will probably have to do to get the code working reliably (for example, if somebody just types a space the check for "" will fail - Google for "javascript trim" to see how to deal with this) but the above should get you started. (Note: I haven't tested the above, so keep an eye out for any typing mistakes I've made :-) Regards, Nick. On Wed, March 11, 2009 2:57 pm, MEM wrote: > Hi all, > > Ok. I have a CSS class to hide divs with the 'display' property. > > The point is: > when the user changes the focus, it displays the "error_div" OF THAT > ASSOCIATED FIELD. > > I have several problems that I can't see to find a solution: > 1) Does not work with IE ! (onsumbit seams having no effect on IE, since > no > matter if the onsubmit is true or false, the form gets submitted!) What > may > be the problem? > > 2) When the onblur() function is executed the function returns the error > message, if a field is empty. Good. But it doesn't make the relation > between > the onblur() of a specific textfield, and that textfield error div > message. > I mean: If we don't type the "name" and the "age" field for example, and > you > click with your mouse over the age field and then, without write anything > inside, you take your mouse away, you will not receive the error: "please > insert your age" but, instead, you will receive "please insert your name", > only because the name comes first. > > 3) When the user touches submit, it shows only one error message at the > time. To see the next error, the user needs to hit submit again. What is > the > technique to search, for displaying all errors at once? > > > I understand that my error is not really related with javascript, is more > related with newbie programming incapacities. But can I please have a > light > about how to solve this issues? > > Here is the code: > > > &&& THE FUNCTION > > function validar(nome,idade,email) { > > var nome = document.getElementById("nome").value; > var idade = document.getElementById("idade").value; > var email = document.getElementById("email").value; > > if (nome == "") { > > > document.getElementById("erro_nome").style.display = "inline"; > document.getElementById("nome").select(); > document.getElementById("nome").focus(); > > return false; > > } > > > else if(idade == "") { > > > document.getElementById("erro_idade").style.display = "inline;" > document.getElementById("idade").select(); > document.getElementById("idade").focus(); > > > return false; > > } > > > else if(email == "") { > > > document.getElementById("erro_email").style.display = "inline;" > document.getElementById("email").select(); > document.getElementById("email").focus(); > > return false; > } > > > return true; > > > } > > > > THE FORM: > >
name="inserir_dados" onsubmit="return validar(nome,idade,email);"> > > > > > > > >
> > > > > > Regards, > M?rcio > > _______________________________________________ > 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 trojani2000 at hotmail.com Wed Mar 11 15:13:14 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Wed, 11 Mar 2009 20:13:14 +0000 Subject: [Javascript] Selecting certain areas of text in a string In-Reply-To: References: Message-ID: Hello Mr. Guillaume, wellcome to the list. If you arre sure that the rest of parameters will allways stay the same than you could, among other go this way: 1. get the url of your object clip source and asign it to some var like: var my_url= //your [object].src which in this case would be: "../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10" 2. extract the current path of the current clip that needs to be changed and asign it to some other string, like: var curr_url = my_url.substring( my_url.indexOf("http://"), my_url.indexOf("&autostart")); alert(curr_url); //alertbox should display: http://www.somesite.com/video/somevideo.flv 3. Than, depending on the method you are using to compose the new source locator of a different clip, take that value and pas it to some var for replacement, or if you are setting it manually, do this: var new_url = my_url.replace(curr_url,"http://www.othersite.com/video/othervideo.flv"); alert(new_url) // will give you the full string of parameters containing the url you've now specified. p.s.: Needless to mention, but for new source to take effect, state: [yourobject].src = new_url; Regards, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > To: javascript at lists.evolt.org > Date: Tue, 10 Mar 2009 16:35:56 +0100 > From: javascript at webdesignofficina.com > Subject: [Javascript] Selecting certain areas of text in a string > > > Hi there, > > Currently trying to change the url of an embedded element in a page... > My problem is that many other parameters are passed along the url of > the object, in the src property: > > src="../pluginsv/mediaplayer.swf?file=http://www.somesite.com/video/somevideo.flv&autostart=true&displayheight=202&allowfullscreen=over&controlbar=over&usefullscreen=true&backcolor=0x121212&frontcolor=0xffffff&lightcolor=0x000000&bufferlength=10" > > I'd like to only rewrite this part: file=http://www.somesite.com/ > video/somevideo.flv > Rest of the parameters should remain untouched... > > I know I should use String.replace, something like: > > var str="somevideo.flv!"; > document.write(str.replace(/somevideo.flv/,"othervideo.flv")); > > But I have absolutely no idea on how target this piece of text only in the > whole src="...", starting from ending file path, from / to .flv > > Any help would be greatly appreciated. > > Thank you. > > Best regards, > > Guillaume Stricher > _______________________________________________ > Javascript mailing list > Javascript at lists.evolt.org > http://lists.evolt.org/mailman/listinfo/javascript _________________________________________________________________ Windows Live?: Life without walls. http://windowslive.com/explore?ocid=TXT_TAGLM_WL_allup_1a_explore_032009 From talofo at gmail.com Thu Mar 12 09:49:07 2009 From: talofo at gmail.com (MEM) Date: Thu, 12 Mar 2009 14:49:07 -0000 Subject: [Javascript] Making a Inline validation using js DOM and CSS part II In-Reply-To: <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> Message-ID: <000f01c9a321$b379c500$1a6d4f00$@com> Ok. I've taken Nicks code. I think it's very nice because it allows us to create a general function, and then, using another function to call that first function with some params. This method of organizing things, allow us to ON upgrading validateField function, to upgrade automatically all validations that we may have made with functionvalidar(); But I have several issues: 1) This works more or less on Firefox (the last field (email), does not ALWAYS show the error message when it should. But I believe he has the same code as the other two. Why is this working with only two fields and not with three? 2) In IE, I get an error when calling the onblur(), it says Error: Object Expected, here: and here, Please take a look here: http://ludmila.uuuq.com/teste_php_pagina_v6.html Any clues about how to solve this issues? Please help, Regards, M?rcio Ps- About the link: the server is a temp one, sometimes you may get a 404 error, but it's a temporary issue. The file is there. From trojani2000 at hotmail.com Thu Mar 12 12:16:38 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Thu, 12 Mar 2009 17:16:38 +0000 Subject: [Javascript] Making a Inline validation using js DOM and CSS part II In-Reply-To: <000f01c9a321$b379c500$1a6d4f00$@com> References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> <000f01c9a321$b379c500$1a6d4f00$@com> Message-ID: The problem is: You are telling IE that the following script is: Will work! Regards, ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > From: talofo at gmail.com > To: javascript at lists.evolt.org > Date: Fri, 13 Mar 2009 02:01:15 +0000 > Subject: Re: [Javascript] Making a Inline validation using js DOM and CSS part II > > Hi, > > Well, I have made that comment because in IE (with field.focus active) the > user cannot choose other field. But if you have (as It's intended) more than > one error message displayed at once, it will be nice to let the user choose > what he/she wants to correct first. That's why I've commented that line. > So I believe that this may not be an issue... > > Thanks, > M?rcio > > > > -----Original Message----- > From: javascript-bounces at lists.evolt.org > [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Troy III Ajnej > Sent: sexta-feira, 13 de Mar?o de 2009 01:10 > To: javascript at lists.evolt.org > Subject: Re: [Javascript] Making a Inline validation using js DOM and CSS > part II > > > > Hello, > > > > how about removing script comments from the line 33, > > that is: > > //field.focus(); > > first? > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > Troy III > progressive art enterprise > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > > > From: talofo at gmail.com > > To: javascript at lists.evolt.org > > Date: Thu, 12 Mar 2009 18:28:44 +0000 > > Subject: Re: [Javascript] Making a Inline validation using js DOM and CSS > part II > > > > > > "You are telling IE that the following script is: > > Cheers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 From talofo at gmail.com Fri Mar 13 18:27:34 2009 From: talofo at gmail.com (MEM) Date: Fri, 13 Mar 2009 23:27:34 -0000 Subject: [Javascript] Making a Inline validation using js DOM and CSS part II In-Reply-To: References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> <000f01c9a321$b379c500$1a6d4f00$@com> <000301c9a340$63506f60$29f14e20$@com> <000001c9a37f$99b85ba0$cd2912e0$@com> Message-ID: <000c01c9a433$4da36110$e8ea2330$@com> Thanks. I was really stuck on this. I will test this tomorrow and post back the progress and the doubts. Thanks a lot, Regards, M?rcio -----Original Message----- From: javascript-bounces at lists.evolt.org [mailto:javascript-bounces at lists.evolt.org] On Behalf Of Troy III Ajnej Sent: sexta-feira, 13 de Mar?o de 2009 23:05 To: javascript at lists.evolt.org Subject: Re: [Javascript] Making a Inline validation using js DOM and CSS part II In fact, shorten the script further, you no longer need returns for the blur/focus events either... (se below) Cheers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 _______________________________________________ Javascript mailing list Javascript at lists.evolt.org http://lists.evolt.org/mailman/listinfo/javascript From trojani2000 at hotmail.com Sun Mar 15 10:38:05 2009 From: trojani2000 at hotmail.com (Troy III Ajnej) Date: Sun, 15 Mar 2009 15:38:05 +0000 Subject: [Javascript] Making a Inline validation using js DOM and CSS part II In-Reply-To: <000c01c9a433$4da36110$e8ea2330$@com> References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> <000f01c9a321$b379c500$1a6d4f00$@com> <000301c9a340$63506f60$29f14e20$@com> <000001c9a37f$99b85ba0$cd2912e0$@com> <000c01c9a433$4da36110$e8ea2330$@com> Message-ID: Hi M?rcio. I've just tested it and it works as intended. I've removed your intermediate function function call, since it doesn't work that way. It is better to supply your function arguments with the needed IDs of your elements directly from the event function call where you can see them. ... ... So you can move your compacted script away from the page, and still preserve a higher level of its readability. But you'll be needing more code and another (better if) separated function for it to become an inteligent form validation function. Regards ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Troy III progressive art enterprise ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > From: talofo at gmail.com > To: javascript at lists.evolt.org > Date: Fri, 13 Mar 2009 23:27:34 +0000 > Subject: Re: [Javascript] Making a Inline validation using js DOM and CSS part II > > Thanks. I was really stuck on this. I will test this tomorrow and post back > the progress and the doubts. > > Thanks a lot, > Regards, > M?rcio > _________________________________________________________________ Windows Live? Groups: Create an online spot for your favorite groups to meet. http://windowslive.com/online/groups?ocid=TXT_TAGLM_WL_groups_032009 From talofo at gmail.com Sun Mar 15 21:14:26 2009 From: talofo at gmail.com (MEM) Date: Mon, 16 Mar 2009 02:14:26 -0000 Subject: [Javascript] Making a Inline validation using js DOM and CSS part II In-Reply-To: References: <38962.87.194.146.163.1236706219.squirrel@easilymail.co.uk> <001301c9a259$b378fe90$1a6afbb0$@com> <41314.87.194.146.163.1236785495.squirrel@easilymail.co.uk> <000f01c9a321$b379c500$1a6d4f00$@com> <000301c9a340$63506f60$29f14e20$@com> <000001c9a37f$99b85ba0$cd2912e0$@com> <000c01c9a433$4da36110$e8ea2330$@com> Message-ID: <001401c9a5dc$ef6a2970$ce3e7c50$@com> Thanks a lot for your time Troy. The function as you have think works very well onblur. Perfectly. :) Sure that, in the future, I want to allow the function to validate the e-mail field, the field.length (maybe instead of having =""), and doing all this in a Reusable Way. Also allow the validation of checkboxes, dropdown, etc... only by calling the function onblur and onsumbit. I will think about that and I will post my progresses. But, a problem that this function have is that, without doing any typing on the textboxes, and then, hiting the submit button, it does not show all error messages. It shows only the first one. So the workaround I've found (on a forum) was to call the function twice. So I have this one: