Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

how to change the div background color on every
refresh..guys can u help me out.

Answer Posted / guest

Try with the following code.
<html>
<body onload="changeColor()">
<script type="text/javascript">
var color=new Array(6);
color[0]="green";
color[1]="#eeeeee";
color[2]="#99CCFF";
color[3]="lavender";
color[4]="pink";
color[5]="#669999";
function changeColor()
{
var ranNum= Math.floor(Math.random()*6);
document.getElementById('div1').style.backgroundColor=color[ranNum];
}
</script>
<div id="div1" name="div1"
style="height:500px;"><center>Changing Color of
div</center></div>
</body>
</html>

Is This Answer Correct ?    27 Yes 5 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between $_files['userfile']['name'] and $_files['userfile']['tmp_name']?

910


How do you remove duplicates from an array?

1036


How to check curl is enabled or not in PHP

1122


What are the popular content management systems (cms) in php?

916


Is apache needed for php?

895


How to create connection in php?

987


How do I display php errors?

958


What is the use of Mbstring?

963


Why php is widely used?

937


Does php 7 support mysql?

991


What is printf in php?

962


How to open standard output as a file handle?

1162


How can we destroy the cookie in php?

972


What are the methods of array in java?

942


What are hooks in php?

943