My first javascript

By pokemaster23 on Jun 08, 2008

Umm...I'm a bit new to Javascript, this is my first script in it o.0

<HTML>
<HEAD>
<TITLE>dot Syntax</TITLE>
<SCRIPT Language="JavaScript">
<!--
function changeLabel(){
  if (document.buttonDemo.HelloWorldButton.value==" Hello "){
    document.buttonDemo.HelloWorldButton.value=" World"
    }
  else{
    document.buttonDemo.HelloWorldButton.value=" Hello "
    }
  }
//-->
</SCRIPT>
</HEAD>

<BODY bgcolor="Red">
<P>
<FORM name="button">
<INPUT type="Button" value=" Hello " name="HelloWorldButton" 
onClick="changeLabel()">
</FORM>
</BODY>
</HTML>

Comments

Sign in to comment.
vaseline28   -  Jul 06, 2008

Definitely is jonesy44!
Although I found other websites more useful for AJAX.

Just noticed in the HTML, there is a

I\'m pretty sure that according to webstandards, all tags must be closed:

and lowecase, all of yours are uppercase.
 Respond  
Jonesy44   -  Jul 02, 2008

w3schools <3 God\'s website :D

 Respond  
vaseline28   -  Jul 02, 2008

All that I know is by trying to write scripts, but beforehand, I picked up the basics from these two links:

http://www.w3schools.com/dhtml/default.asp
http://www.w3schools.com/htmldom/default.asp

Work through those and you\'ll be an expert!

 Respond  
ChunkieMonkey   -  Jul 01, 2008

vaseline28, Do you know any sites that can help me learn a bit on DHTML?

 Respond  
vaseline28   -  Jul 01, 2008

Excellent MountainDew!

pokemaster23:
You could write this much more simply through use of DHTML:

<INPUT type=\"Button\" value=\"Hello\" onclick=\"this.value=\'World\'\" >
When clicked, it changes to \'World\'. You can also specify it to when it is hovered over, hovered out etc. For example:
<INPUT type=\"Button\" value=\"Hello\" onclick=\"this.value=\'World\'\" onmouseover=\"this.value=\'mouse\'\" >
When the mouse hovers over, it returns \'mouse\'

 Respond  
guest598594   -  Jun 30, 2008

Ah, I get it now :)

 Respond  
vaseline28   -  Jun 30, 2008

@MountainDew:

The Javascript comment looks different (/*) to an HTML one (<!--)
They use this so that a browserwhich does not support Javascript will not display the Javascript as plain text. A browser which does support Javascript will see the <script type=\"text/javascript\"> and ignore the HTML comment.

 Respond  
Jonesy44   -  Jun 16, 2008

It\'s useless.
But i must argue; onClick does work .. the capitalizing each word is just a habit. JS does not actually change, or not work with or without it.

 Respond  
markusPHP   -  Jun 16, 2008

Whoa, guys, calm down.

type attribute missing - error 1.
semi-colons missing - not an error, but good fashion.
Elements in uppercase - Won\'t validate.
onClick There is no such attribute; it\'s onclick

What I don\'t understand is, how can post such a pointless code in the snippets section? There\'s no use to it.

 Respond  
ChunkieMonkey   -  Jun 11, 2008

Why post something un-original to a bunch of people who have read the whole www .. twice..

ROFL

 Respond  
Jonesy44   -  Jun 11, 2008

L.A.M.E LoL

Why post something un-original to a bunch of people who have read the whole www .. twice..

 Respond  
pokemaster23   -  Jun 09, 2008

Ummm....I dun feel like searching. google javascriptmall lesson 7

 Respond  
EL   -  Jun 09, 2008

Link?

 Respond  
pokemaster23   -  Jun 09, 2008

First, I didn\'t copy a damn thing for JS. Yea, I admit I have ripped once before, but this script is a bit like the one from Javascriptmall. I use that site to help me, I saw this on the assignments page for lesson 7 so I decided to try to write it, or something similar.

 Respond  
Jonesy44   -  Jun 09, 2008

Yes, MD lol

 Respond  
EL   -  Jun 09, 2008

@Eugene,wtf i wouldnt be proud of that ya putz.`-.-´

 Respond  
guest598594   -  Jun 09, 2008
<!--
function changeLabel(){
  if (document.buttonDemo.HelloWorldButton.value==\" Hello \"){
    document.buttonDemo.HelloWorldButton.value=\" World\"
    }
  else{
    document.buttonDemo.HelloWorldButton.value=\" Hello \"
    }
  }
//-->

Isn\'t that treated as a comment?

 Respond  
Eugenio   -  Jun 09, 2008

Well tbh he rips and he doesnt even try to hide it he knows and we all know, so if he must do it cant he atleast try to disguise it ffs or why is he here ?!?
Im not that bad.....I tend to butcher codes :p and edit them alot but I dont do this.

 Respond  
EL   -  Jun 09, 2008

Lol@this yeah from wat i see of yur mIRC snippets you should prolly READ and TRY the tuts and try not to mimic whats there.`-.-´

 Respond  
Jonesy44   -  Jun 09, 2008

From his other scripts.. Uhh, i think this guy is a bit of a joke :/

 Respond  
F*U*R*B*Y*   -  Jun 09, 2008

Noutrious half these scripts are either buggy or ripped ;)

 Respond  
Noutrious   -  Jun 09, 2008

That\'s not your javascript, you copied it from tutorial sites @ internet, have seen this before.
Why are you sucha lamer?

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.