UK Webmaster Talk - Online Marketing - SEO


 

Java Variables

This is a discussion on Java Variables within the Programming Articles forums, part of the Webmaster Articles/Tutorials category; Variables. What's a variable? Let's suppose x=5. x is a variable. At the time of the statement, x happens to ...


Go Back   UK Webmaster Talk - Online Marketing - SEO > Webmaster Articles > Webmaster Articles/Tutorials > Programming Articles

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Notices

Reply

 

LinkBack Thread Tools Display Modes
Old 26-06-2005, 18:49   #1 (permalink)
Ultimo Supremo
 
Join Date: May 2005
Location: /public_html/Cgi-bin/
Posts: 1,417
iTrader: 0 / 0%
Morphmaster is a glorious beacon of light
Send a message via MSN to Morphmaster
Default Java Variables

Variables.

What's a variable? Let's suppose x=5.

x is a variable. At the time of the statement, x happens to be 5. Can x be something else? Sure, x=6. Now x equals 6. (Hence the name "variable"... it's value can vary.)

Can a variable be something other than a number? Sure. How about x="Joe". Now x equals the string "Joe". (A string by the way is a string of characters).

Can the name of a variable be something other than a letter like x? Sure, myname="Joe". Simple.

How can we incorporate this new found knowledge into our function? Easy...

<HTML>
<HEAD>
<TITLE></TITLE>

<SCRIPT language="javascript"><!--

function HelloWorld()
{
myname = "Joe";
alert (myname);
}

//--></SCRIPT>

</HEAD>
<BODY>

<A HREF="javascript:HelloWorld()">Hello</A>

</BODY>
</HTML>

Try it.

(Note the first example had quotes around the string in the alert command*, but when we used a variable, there were no quotes.)

*Technically it's the alert method, but we'll get into that later. Command is fine for now and is probably a better description anyway :-)

We could make it say Hello + variable...

<HTML>
<HEAD>
<TITLE></TITLE>

<SCRIPT language="javascript"><!--

function HelloWorld()
{
myname = "Joe";
alert ("Hello " + myname);
}

//--></SCRIPT>

</HEAD>
<BODY>

<A HREF="javascript:HelloWorld()">Hello</A>

</BODY>
</HTML>
__________________
Thanks
Tom

Have you ever thought what it's like, to be wanderers in the fourth dimension? Have you? To be exiles?
Morphmaster is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Tags
java, variables

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

Similar Threads

Thread Thread Starter Forum Replies Last Post
Small java codes need? godofdomains Programming / Scripting / Coding 5 04-06-2005 02:58


All times are GMT +1. The time now is 16:45.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
UK Webmaster Forum © WebmasterTalk.co.uk | Design by Forbairt

Ad Management by RedTyger

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41