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 / kapil dhiman

<?php

// Class
class ChangeDivColor{

public function __construct(){

$value= array("#000000","#CC0000","#009900","#6600CC","#FFFF00");
$rand_keys=array_rand($value,2);

echo '<div style="height:200px; width:200px; float:left; background:'.$value[$rand_keys[0]].';"></div>';


}
}

$obj= new ChangeDivColor()


// inline coding
$value= array("#000000","#CC0000","#009900","#6600CC","#FFFF00");
$rand_keys=array_rand($value,2);
?>
<div style="height:200px; width:200px; float:left; background:<?=$value[$rand_keys[0]]?>;"></div>

Is This Answer Correct ?    5 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How long does a php session last for?

1034


Inside a php function, what param needs to be set in order to access a global variable?

972


What is the method to register a variable into a session?

849


What are examples of independent and dependent variables?

948


Explain me soundex() and metaphone()?

991


What is an abstract class in php?

966


What are the four scalar types of php?

1121


What are helpers in php?

945


What are computer variables?

947


Which of the delimiter is ASP style?

1083


What is the use of trim function in php?

970


Why php script is not running in browser?

1045


How can we destroy the cookie in php?

987


Tell me what the difference between the 'bitwise and' operator and the 'logical and' operator?

962


What is x+ mode in fopen() used for?

1045