PDA

View Full Version : Javascript tutorial



splintercell!
13-07-2005, 05:38 PM
Javascript is quite an old language now and is usually replaced by its more advanced and modern partners php, asp etc. but its still very useful in places and a good language to learn. It is useful for people with non php supported hosts such as freewebs because they can perform variable functions using javascript.

So lets start off as all tutorials should! Lets say HELLO WORLD! To write a basic statement in Javascript you need to use the following code:


<script type="text/javascript">
document.write("Hello World!")
</script>

this will the produce the statement in your browser Hello World! but this is the most simple state of javascript.

Next we move onto variables. This is very much the same as php. See below:


<script type="text/javascript">
var phrase = "Hello World!"
document.write(phrase)
document.write("<h1>"+phrase+"</h1>")
</script>

so here the script take the statement Hello World and in the document.write tag it more or less calls for it.

Last I am going to show you the If statement. It goes something like this:


<script type="text/javascript">
var d = new Date()
var time = d.getHours()

if (time < 10)
{
document.write("<b>Good morning</b>")
}
</script>

This simply checks the time and if it is before 10am then it displays the message Good morning. This can be very useful in welcoming messages on your site.

Hopefully this will have given you a little insight into the world of javascript.

[Edited By partie2] (Forum Moderator) Thread Stuck, Great Job :)

-JT-
13-07-2005, 10:22 PM
very, very nice, i like it

Jseb
13-07-2005, 11:25 PM
Wow I didn't know really javascript but now it does make since. I love it

partie2
14-07-2005, 07:03 AM
Great Job so ive moved the thread and stuck it in Website Tutorials Well Done :)

Lysine
02-08-2005, 07:50 PM
VERY GOOD
10/10
:)

.Lesley.
23-09-2005, 05:22 PM
Really Cool!

i dont think it works for myserver though

Mentor
23-09-2005, 05:42 PM
Javascript is quite an old language now and is usually replaced by its more advanced and modern partners php, asp etc. but its still very useful in places and a good language to learn. It is useful for people with non php supported hosts such as freewebs because they can perform variable functions using javascript.
Urmm im not sure if im misreading but javascript and php/asp are more aless complty differnt, and do complty differnt things, nether can do teh others job?
Javascript is client size, so has controls to work once loaded to the user, wich are exicuted by the browser, say reszing screens active javascript content, that can change stuff without the need to reaload pages.
Php/asp are server side, meaing none of it gets to the user, the host server, runs all the php or asp files, before it sends anything, and waht it does send is the pure dinamicly genoirated, but otherwize ordanry html file, possibly with javascript.

so i dont get your comparson, its like comparing a image to aduio files "/

splintercell!
23-09-2005, 07:11 PM
I really meant in a more basic sense such as with variables etc. Obviously javascript is cant do anything as advanced as php but in their basics they can be abit compared.

Mentor
23-09-2005, 07:53 PM
I really meant in a more basic sense such as with variables etc. Obviously javascript is cant do anything as advanced as php but in their basics they can be abit compared.
Well javascipt can do things just as advanced as php, you cant get php to make someones browser bounce around the desk top, just as you cant get javascript to run a forum on "/
Id still say the equal, overall and just serve diffent purpos's

Tom H
25-09-2005, 11:50 AM
Wow That is pure class, I have never really noticed javascript as such a powerful language and thats just impressive!!

Crouch
26-09-2005, 05:28 PM
Woah, Great tutorial. We really did need one like this..

matt9875
06-10-2005, 07:14 PM
finally ime starting to understand javascript :P

Want to hide these adverts? Register an account for free!