Web Hosting Deals Holiday Logo Design Webcam Chat Website Header Templates Register domain Search Engine Optimisation Web Hosting
Go Back   Talk Mania Forum > Tutorials > PHP / Perl / Java / JavaScript / CGI Tutorials

PHP / Perl / Java / JavaScript / CGI Tutorials PHP / Perl / Java / JavaScript / CGI Tutorials Please do not use this Forum to advertise your site or to link to tutorials.

 Image
Buy Sell Downloads

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-30-2007, 03:38 PM
Scorpian8867's Avatar
Junior Member
 
Join Date: Feb 2007
Location: Texas
Posts: 24
Scorpian8867 is on a distinguished road
Send a message via AIM to Scorpian8867 Send a message via MSN to Scorpian8867
[JS] Scorpian's Guide to JavaScript P.1

Are you a noob? Do you have no clue what JavaScript does? Do you want to learn? Fear not, for I am here to help! I'll guide you through all of the basics of JavaScript in these few, simple tutorials.

First off, it's imperitive that you never get Java & JavaScript confused. Yes, they have similar names. However, that's the only similarity. They are two completely different languages that are meant to do completely different things. When NetScape made JavaScript, they decided to name it that since Java was already popular. It helped JavaScript grow pretty well. Now, just about every browser on the planet supports it.

First off, let's learn how to set-up a code tag. You can do this by two ways.
1.) You can embed your code with script tags.
2.) You can remotely host it.

It doesn't matter which way you use, as you'll need to use script tags for both. So, let's learn how to set them up. A script tag is just an HTML element that let's the browser know that it needs to read everything in it as another type of script. It's mainly used for JavaScript. The layout is pretty simple.

<script type='text/javascript' src='myscript.js'></script>

I have color-coded this for you. The red parts are the script tags themselves. This is what tells the browser to stop reading HTML, and read a type of script. The blue part tells the browser that the type of script it's going to be reading is JavaScript in a text format. Now, the green part is optional. If you remotely host your code, this is what tells the browser where it can find the script. It's used just like when you link to a stylesheet or image. Leave it out if you're not using a seperate script.

Now, let's learn the basics. Here's a code with some pretty simple elements of JavaScript that we'll learn:

<script type='text/javascript'>
// This line is a comment

/* This is all
a comment */


var varName = "Variable Value";
</script>


Alright, the maroon parts are the opening & closing tags of our JavaScript segment. Everything you want to write in JavaScript goes between them. The gray parts are comments. If you want to write something that the browser shouldn't pay attention to, you can comment it out, just like you comment in HTML. For a one-line comment, use //. For a multiple-line comment, start it with /*, and end it with */.

The bold navy part is what we use to define a varaible. Simply start a line with "var", followed by a space, and put the variable name, shown in black. Next, we'll add an equal sign, followed by the value of the variable. This is the part in blue, surrounded by quotes. Some things to note about variables is that you can combine different things into a variable using a + sign. For example:

var myName = "Scorpian";
var welcomeMessage = "Welcome, " + myName + ", to our site!";


This defines "Scorpian" as the value of myName. It then defines welcomeMessage as "Welcome, ", then whatever the value of myName is, and ", to our site!". This is very useful in simplifying scripts.

You can also define multiple variables in one line if they all have the same value. For example:

var myMoney = myFunds = "3";

That shows that the variable myMoney will equal whatever the value of myFunds is, which we define as three. You may feel free to define as may variables as you want this way. Just seperate them with equal signs.

Well, that sums up the most basic of the basics for this tutorial. Next tutorial, we'll learn how to use these variables. We'll also learn the infamous alert box, and how to use it. Stay tuned, folks.

__________________
RoddyInnovations.com
Reply With Quote
  #2 (permalink)  
Old 04-04-2007, 08:10 AM
Junior Member
 
Join Date: Mar 2007
Posts: 20
kraze101 is on a distinguished road
im always interested in learning new stuff. thanks for this . if i run into any problems java related lol ill be sure to ask you.

*javascript
Reply With Quote
  #3 (permalink)  
Old 04-04-2007, 11:24 PM
Scorpian8867's Avatar
Junior Member
 
Join Date: Feb 2007
Location: Texas
Posts: 24
Scorpian8867 is on a distinguished road
Send a message via AIM to Scorpian8867 Send a message via MSN to Scorpian8867
Java and JavaScript are two completely different things. If you come to me with a Java problem, you'll leave pretty disappointed. I don't know Java. XD
__________________
RoddyInnovations.com
Reply With Quote
  #4 (permalink)  
Old 04-05-2007, 06:14 AM
Junior Member
 
Join Date: Mar 2007
Posts: 20
kraze101 is on a distinguished road
haha yea i know i was just kiding since u made that very clear in your tut thanx
Reply With Quote
  #5 (permalink)  
Old 04-05-2007, 06:19 PM
Base's Avatar
Senior Member
 
Join Date: Mar 2007
Location: North Yorkshire, UK
Posts: 121
Base is on a distinguished road
Send a message via MSN to Base Send a message via Skype™ to Base
"Java and JavaScript are two completely different things."

Nope they are not

They are both similar and quite different depending on how you look at them.

Java is an Object Oriented Programming (OOP) language created by James Gosling of Sun Microsystems. JavaScript was created by the fine people at Netscape. JavaScript is a distant cousin of Java. It is also an OOP language. Many of their programming structures are similar. However, JavaScript contains a much smaller and simpler set of commands than does Java. It is easier for the average weekend warrior to understand.

So they are not "completely different" after all!

Base
__________________
http://www.pointserv.co.uk/gfx/deal_..._pointserv.png
PointServ.co.uk - One of the UK's cheapest webhosting companies.
Reply With Quote
  #6 (permalink)  
Old 04-05-2007, 09:58 PM
Junior Member
 
Join Date: Mar 2007
Posts: 20
kraze101 is on a distinguished road
thank you for the heads up
Reply With Quote
  #7 (permalink)  
Old 04-05-2007, 11:34 PM
Scorpian8867's Avatar
Junior Member
 
Join Date: Feb 2007
Location: Texas
Posts: 24
Scorpian8867 is on a distinguished road
Send a message via AIM to Scorpian8867 Send a message via MSN to Scorpian8867
Good point, Base. I never really thought of it in that matter. They still are made for different purposes, though. While Java is an advanced programming language, JavaScript is just a browser scripting language that's supported by like 99% of current browsers. Java can also be used, but the user needs to have a Java console installed because of its complexity.

Also, the layout is different in many aspects. However, it's still similar enough to where it can't be "completely" different. I don't really care for political correctness, though, so we'll just keep it that way.

__________________
RoddyInnovations.com
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT +2. The time now is 01:34 AM.


Fake ID

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC8
Forums Copyright © Talk-Mania.com