From: Richard Cornford on 3 Aug 2010 10:36 On Aug 3, 2:58 pm, Tim Streater wrote: > Richard Cornford 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? > > Are you pulling my leg? Why would you want to do that? Code > with syntax errors has no meaning. You fix the errors and then > proceed. I was trying to point out that the proposition that single stepping thorough the code with a debugger should be attempted by the OP is inappropriate when the code in question clearly contains syntax errors and so will not even compile, let alone run. Richard.
From: Richard Cornford on 3 Aug 2010 13:17 On Aug 3, 2:44 pm, Jeff North wrote: > Richard Cornford 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. The answer is that code containing syntax errors cannot be complied, so cannot be executed and so cannot be single stepped through. Better advice for a beginner would be to use/look at the error console, or whatever error reporting mechanism the browser(s) they are using provides, and start learning to understand the messages it produces. Where syntax errors are going unnoticed that is more the level of information that the OP needs. Richard.
From: Jeff North on 3 Aug 2010 18:11 On Tue, 3 Aug 2010 10:17:40 -0700 (PDT), in comp.lang.javascript Richard Cornford <Richard(a)litotes.demon.co.uk> <c365b5db-4d4e-47d7-bc5b-0f8a7d57f6df(a)5g2000yqz.googlegroups.com> wrote: >| On Aug 3, 2:44 pm, Jeff North wrote: >| > Richard Cornford 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. >| >| The answer is that code containing syntax errors cannot be complied, >| so cannot be executed and so cannot be single stepped through. Better >| advice for a beginner would be to use/look at the error console, or >| whatever error reporting mechanism the browser(s) they are using >| provides, and start learning to understand the messages it produces. >| Where syntax errors are going unnoticed that is more the level of >| information that the OP needs. Sweetheart, go back to my origin post and you will see that I did mention the console. A section that *you* snipped!
From: RobG on 3 Aug 2010 19:15 On Aug 3, 11:26 pm, jr <jlro...(a)yahoo.com> wrote: > 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, Yes. Input elements don't have an onsubmit attribute so your listener is not being called. Form elements do, move the onsubmit listener to the form. -- Rob
From: Thomas 'PointedEars' Lahn on 4 Aug 2010 16:24 Jeff North wrote: > Richard Cornford wrote: >>| On Aug 3, 2:44 pm, Jeff North wrote: >>| > Richard Cornford 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. >>| >>| The answer is that code containing syntax errors cannot be complied, >>| so cannot be executed and so cannot be single stepped through. Better >>| advice for a beginner would be to use/look at the error console, or >>| whatever error reporting mechanism the browser(s) they are using >>| provides, and start learning to understand the messages it produces. >>| Where syntax errors are going unnoticed that is more the level of >>| information that the OP needs. > > Sweetheart, Given your rather naive response to Richards thought-provoking question, there is no reason for you to feel attacked by Richard's explanation, and no need to fight back anyway. I think an apology from you to Richard is in order. > go back to my origin post and you will see that I did > mention the console. A section that *you* snipped! However, while Firebug is certainly a useful tool for Web developers, it does not take the Firebug Console for a syntax error in a client-side script to be displayed. There is a *built-in* Error Console in most Mozilla-based browsers that can be triggered with a menu item (the Tools menu has it in Iceweasel 3.6.3) or entering `javascript:' in the Location Bar. That hint suffices for an answer to a beginner at that position in the learning curve. PointedEars -- realism: HTML 4.01 Strict evangelism: XHTML 1.0 Strict madness: XHTML 1.1 as application/xhtml+xml -- Bjoern Hoehrmann
First
|
Prev
|
Pages: 1 2 3 Prev: When window open closed Next: validation has syntax errors [correction] |