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

Tell me how to find the length of a string?

1124


How do I start a php session?

1042


Can I learn laravel without php?

1073


Explain the changes in php versions?

1027


Is php a float?

1082


What is php limit?

1155


How many ways to include array elements in double-quoted strings using php?

1107


What is a collection in php?

1002


Is php open source?

1068


How many types of session are there?

1072


What is the current stable version of php?

1089


Why do you need to filter out empty files?

983


What is the meaning of symbol '$' in jquery?

1131


Is it possible to remove the html tags from data?

971


What is session in PHP. How to remove data from a session?

1047