Fun Stuff > CLIKC

Need help (lots) with Javascript

<< < (12/13) > >>

Sorflakne:

--- Quote ---Sorflakne, can you post your code? It'd help to be able to look at it.
--- End quote ---
I'm trying to remember which one it was (I've made several...serves me right for not giving each a unique name), but if I do, I'll post it.

On the topic of ASP stuff, the book I'm using has its ASP examples "written in VBScript for an Internet Information Server", to quote from it, and then has the file saved with an .asp extension.  Why do this, if the file is saved as .asp?  I get that for me this is rather advanced stuff so maybe I'm not seeing the reasoning for doing this yet (or maybe the book is wrong and you're not supposed to do this), but why not write the files in ASP and save them as such?  And on a similar subject, between ASP and PHP, which is the preferred coding, or are there times where one or the other is specifically required?


--- Quote ---Other than that I cannot see what the problem could be, are you using anything to debug the Javascript? Even Chrome comes with a developer console, very handy.
--- End quote ---
I'm going to the console in Firefox and selecting Debug Mode, but nothing happens.  It displays the page code, but there's no indicators for stuff that's wrong, no way to manipulate text or whatnot...not really sure how to use it.

bryntheskits:
ASP is more Windows based servers, while PHP is any (that's how I see it). I prefer PHP much more, and interact with more things and well I grew up with it so maybe I'm bias.

I don't use Firefox but there should be a console somewhere in the Developers part, there is in Chrome anyway.

https://developer.mozilla.org/en-US/docs/Tools/Web_Console

You should also be able to change code on the fly using the Inspecter (I think :P)

Loki:
This is just a guess, but:

A button can stand alone pretty much anywhere in the document [1]. An input MUST be within a form tag to confirm to the HTML standard, so that may be the problem.

Pretty sure there is no standard on attribute lower/upper case in the HTML specification. XHTML requires all lowercase. Are you using any document type declaration? If not, you should probably choose one (I think nowadays it doesn't really matter if you choose HTML5 or XHTML.) The important thing is that you stick to it. Make sure your HTML code uses the right syntax using http://validator.w3.org/.

The DTD basically tells the browser - any properly-programmed browser "hey, I am doing things this way". If you do things wrong, the browser will try to correct your code to what it thinks it should be, but it may be wrong.

No idea about ASP at all, sorry. However note that you can configure your server to treat any extension as anything you want, it is just not a good idea to do so. (You can also configure your PC to open all mp3-files with an image viewer, but that won't be a good idea either).

You might want to use http://www.jslint.com/ for validating the Javascript syntax. You will probably want to check at least the following:

Assume:
a browser,
console, alert,..

Tolerate...
assignment expressions
bitwise operators
continue
== and !=
++ and --
unused parameters

everything in the fourth column.

Sorflakne:
Eh, most of the examples I've seen don't have <form> tags around the buttons if they're standalone.  Now if the buttons are connected with a text box or are otherwise more than just the button itself, then yeah, they pretty much all have <form> tags.

So between PHP and ASP, is it better to get smart on one and have at least a basic understanding of the other, or should a person know both about equally?

Also gave JSLint a try, and it kept telling me that I was missing "use strict" statements all over my code.  I've never heard of this, is "use strict" required for javascript writing?  Some of the info I've found says you can just put it in the first line of your javascript page, assuming you have all your stuff saved to a separate file from the webpage itself, and others say you can simply write it into its own function...how would you write a function for it?

On the other hand, JSLint seems nice, but it keeps giving back "so-and-so has not been defined"; it even does this for alert(); lines...how do you define alert(); (yes, there is messages enclosed by "" in them :P )?  I mean, the code I'm writing is modified from the book I'm using and trying to follow a similar format to it, which works fine when directly copied and tested in the browser, but JSLint keeps coming back with undefined's for the book's stuff and my own, even when adding exceptions in the Tolerate options.

Loki:
*shrug*  I know my PHP and not a hint of ASP, served me well enough so far. (Of course, I don't program that much anymore. I study Computer Sciences after all.)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version