EVILSOFTS...
Would you like to react to this message? Create an account in a few clicks or log in to continue.


TOTALLY EVILINSIDEZZ...
 
HomeLatest imagesSearchRegisterLog in

 

 Java script - Change color

Go down 
2 posters
AuthorMessage
devendra
developer
developer



Posts : 3
Join date : 2010-09-21

Java script - Change color Empty
PostSubject: Java script - Change color   Java script - Change color Icon_minitimeWed Sep 22, 2010 5:57 am

HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

function changecolor(code) {

document.bgColor=code
}
// - End of JavaScript - -->
</SCRIPT>

</HEAD>
<BODY>

<form>
<input type="button" name="Button1" value="RED" onclick="changecolor('red')">

<input type="button" name="Button2" value="GREEN" onclick="changecolor('green')">

<input type="button" name="Button3" value="BLUE" onclick="changecolor('blue')">

<input type="button" name="Button4" value="WHITE" onclick="changecolor('white')">

</form>

</BODY>
</HTML>





CODE BREAK DOWN




function changecolor(code) {
document.bgColor=code
}


--------------------------------------------------------------------------------

This page is an excellent example of one function being used by several buttons in the same document. Our function is called changecolor(code). It has only one line:
document.bgColor=code.

You probably guessed that bgColor stands for background color.
If I type document.bgColor="red" the background will turn red.

By writing the command document.bgColor=code I am allowing myself to define the variable code as any color I want.

Later, in the form. I define a button with the command:
onClick="changecolor('green')"

onClick="changecolor('green')" is telling the program 2 things:


Run the funtion named changecolor(code).
code='green'

Back to top Go down
Admin
Admin
Admin
Admin


Posts : 44
Join date : 2010-09-20
Age : 34
Location : mumbai

Java script - Change color Empty
PostSubject: Re: Java script - Change color   Java script - Change color Icon_minitimeWed Sep 22, 2010 11:49 am

wow nyc sharing devendra, this script is very helpful in web designing... thanks for sharing it Very Happy keep sharing more Twisted Evil
Back to top Go down
https://evilsofts.forumotion.com
 
Java script - Change color
Back to top 
Page 1 of 1
 Similar topics
-
» Learn JAVA Script - BASICS

Permissions in this forum:You cannot reply to topics in this forum
EVILSOFTS... :: DEVELOPING TOOLS-
Jump to: