From: Richard Cornford on
On Aug 3, 9:59 am, Jeff North wrote:
> On Mon, 2 Aug 2010 jr wrote:
<snip>
> >| function checkscript() {
> >|   if (ele.search_bu.value ) && (ele.search_error_flag.value )
<snip>
>
> Please download and install firefox then download and install
> firebug. Next, learn how to use firebug to single step through
> your code. You will learn a lot more and also be able to fix
> a lot of these errors yourself.

Is it possible to single step through code that contains syntax
errors?

Richard.
From: jr on
On Aug 3, 1:01 am, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
> jr wrote:
> > function checkscript() {
> >   if (ele.search_bu.value ) && (ele.search_error_flag.value )
>
> It is really good idea to read the syntax of `If Statement`.
>
>    if ( Expression ) Statement
>
> And from this point:
>
> && (!ele.search_zonenm.value)
>
> This part should be parse as Statement and in ECMAScript there is not
> Statement which start with:
>
> &&
>
> Even and Expression Statement.
> So the expected result here is SyntaxError.
>
> Start reading:
> <URL:http://www.jibbering.com/faq/>
> <URL:https://developer.mozilla.org/en/Core_JavaScript_1.5_Guide/>
>
> And ECMA-262 standard.

thanks that was it.
From: jr on
On Aug 2, 11:25 pm, RobG <rg...(a)iinet.net.au> wrote:
> On Aug 3, 4:04 pm, jr <jlro...(a)yahoo.com> wrote:
>
> > There are two required fields,  bu and error flag, also if zoneid is
> > selected  they must also have a value for the zonenm .  I am having
> > trouble figuring out where to return the 0 or the 1 so that it returns
> > false or true but I have the right conditions,
> >  thanks,
> > function checkscript() {
> >   if (ele.search_bu.value ) && (ele.search_error_flag.value )
> >        {
> >            if (ele.search_zoneid.value) && (!ele.search_zonenm.value)
>
> >         else{return 0;}
>
> Why not return a boolean instead of a string?
>
> >        }
> >  else {return 1;}
>
> Where is the closing brace for the function? Why not return boolean
> true?
>
> >  </script>
>
> Your code would be much easier to read if it was written as:
>
>   function checkscript() {
>
>     // If bu and error_flag have a value
>     if (ele.search_bu.value ) && (ele.search_error_flag.value ) {
>
>       // If zoneid has a value and zonenm doesn't
>       if (ele.search_zoneid.value) && (!ele.search_zonenm.value) {
>         // do something?
>
>       } else {
>         // if zoneid doesn't have a value, or
>         // if both zoneid and zonenm have values
>         return 0;
>       }
>
>     // If either bu or error_flag (or both) don't have a value
>     } else {
>       return 1;
>     }
>   }
>
> The comments can be removed once you are happy the logic is correct.
> The formatting and extra braces should stay, they cost nothing to
> include and make life far more pleasant for others (and usually the
> athor also) to follow the code. And find mistakes.
>
> It should also help with minifying.
>
> --
> Rob

okay, there are no syntax errors now but it still doesn't validate.
Just to double check I'm posting it with
the comments and logic how I think it should be. If there isn't an
error here does that mean there is an error in the html
that is blocking the validation from happening? thanks,

function checkscript() {
// If bu and error_flag have a value return 0, if zoneid has a value
without zonenm proceed to next check
if (ele.search_bu.value && ele.search_error_flag.value ) {
// If zoneid has a value and zonenm does not have a value
return false
if (ele.search_zoneid.value && !ele.search_zonenm.value) {
return 1;
} else {
// if zoneid doesn't have a value, or
// if both zoneid and zonenm have values
return 0;
}
// If either bu or error_flag (or both) don't have a value
} else {
return 1;
}
}
From: jr on
On Aug 2, 11:25 pm, RobG <rg...(a)iinet.net.au> wrote:
> On Aug 3, 4:04 pm, jr <jlro...(a)yahoo.com> wrote:
>
> > There are two required fields,  bu and error flag, also if zoneid is
> > selected  they must also have a value for the zonenm .  I am having
> > trouble figuring out where to return the 0 or the 1 so that it returns
> > false or true but I have the right conditions,
> >  thanks,
> > function checkscript() {
> >   if (ele.search_bu.value ) && (ele.search_error_flag.value )
> >        {
> >            if (ele.search_zoneid.value) && (!ele.search_zonenm.value)
>
> >         else{return 0;}
>
> Why not return a boolean instead of a string?
>
> >        }
> >  else {return 1;}
>
> Where is the closing brace for the function? Why not return boolean
> true?
>
> >  </script>
>
> Your code would be much easier to read if it was written as:
>
>   function checkscript() {
>
>     // If bu and error_flag have a value
>     if (ele.search_bu.value ) && (ele.search_error_flag.value ) {
>
>       // If zoneid has a value and zonenm doesn't
>       if (ele.search_zoneid.value) && (!ele.search_zonenm.value) {
>         // do something?
>
>       } else {
>         // if zoneid doesn't have a value, or
>         // if both zoneid and zonenm have values
>         return 0;
>       }
>
>     // If either bu or error_flag (or both) don't have a value
>     } else {
>       return 1;
>     }
>   }
>
> The comments can be removed once you are happy the logic is correct.
> The formatting and extra braces should stay, they cost nothing to
> include and make life far more pleasant for others (and usually the
> athor also) to follow the code. And find mistakes.
>
> It should also help with minifying.
>
> --
> Rob

THis is the submit button from view source:
<td colspan='13' align='center'><input type='submit' name='submit1'
value = ' Search' onSubmit=" return checkscript();">

Is there anything wrong with my submit button? thanks,
From: Jeff North on
On Tue, 3 Aug 2010 03:59:19 -0700 (PDT), in comp.lang.javascript
Richard Cornford <Richard(a)litotes.demon.co.uk>
<ab8e2835-f701-4374-a6a3-edcf3c8d8f0a(a)w30g2000yqw.googlegroups.com>
wrote:

>| On Aug 3, 9:59�am, Jeff North wrote:
>| > On Mon, 2 Aug 2010 jr wrote:
>| <snip>
>| > >| function checkscript() {
>| > >| � if (ele.search_bu.value ) && (ele.search_error_flag.value )
>| <snip>
>| >
>| > Please download and install firefox then download and install
>| > firebug. Next, learn how to use firebug to single step through
>| > your code. You will learn a lot more and also be able to fix
>| > a lot of these errors yourself.
>|
>| Is it possible to single step through code that contains syntax
>| errors?

I wouldn't know as my code never has syntax errors.