Here you can find a number of examples on Java Script.Please find the various kinds of examples listed on the right side of this site. If you don't find anything on Java Script then please write to us or leave a commnet. We are pleased to help and find the solution of your problem.
Showing posts with label onclick. Show all posts
Showing posts with label onclick. Show all posts

Javascript: Change Background Color



<html>
<head>
<title>Change Color on click Cheskbox</title>

<script language="javascript">
function rcolor()
{
document.bgColor=f1.c1.checked ? "lightblue" : "white";
}
function lgcolor()
{
document.bgColor=f1.c2.checked ? "lightgrey" : "white";
}
function lycolor()
{
document.bgColor=f1.c3.checked ? "lightyellow" : "white";
}
</script>

</head>
<body>

<form name=f1>
<input type="checkbox" name=c1 onclick="rcolor()">Lightblue<br>
<input type="checkbox" name=c2 onclick="lgcolor()">Lightgrey<br>
<input type="checkbox" name=c3 onclick="lycolor()">Lightyellow <br>
</form>

</body>
</html>

Javascript: Chage Background and Foreground Color onclick button



<html>
<head>

<script language="javascript">
function changebg(thecolor)
{
document.bgColor=thecolor.value;
}

function changefg(thecolor)
{
document.fgColor=thecolor.value;
}
</script>

</head>
<body>

<b>Background</b>

<form>
<input type=button value="red" onclick="changebg(this)">
<input type=button value="black" onclick="changebg(this)">
<input type=button value="lightyellow" onclick="changebg(this)">
<input type=button value="lightgrey" onclick="changebg(this)">

<p>
<b>Foreground</b>

<b<Welcome to my site</b><p>
<input type=button value="white" onclick="changefg(this)">
<input type=button value="blue" onclick="changefg(this)">
<input type=button value="brown" onclick="changefg(this)">
<input type=button value="darkblue" onclick="changefg(this)">
</form>

</body>
</html>
Google