CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Java

 Random color help please

Print topic Send  topic

Author Message
Rob


Posts: 13
Posted: 04/06/2007, 11:35 AM

This code is working fine but it only changes 1st div's innerHTML i need a random colorcode for each div.
could anyone help me out?
Code:
  
<html>  
  
<head>  
<title>Title</title>  
</head>  
  
<body topmargin="0" leftmargin="0">  
<div id='cr' style="width: 394; height: 112">x</div>  
<div id='cr' style="width: 394; height: 112">x</div>  
<div id='cr' style="width: 394; height: 112">x</div>  
<script language="JavaScript">  
<!-- Begin  
rnd.today=new Date();  
rnd.seed=rnd.today.getTime();  
  
function rnd() {  
        rnd.seed = (rnd.seed*9301+49297) % 233280;  
        return rnd.seed/(233280.0);  
};  
  
function rand(number) {  
	var result = Math.ceil(rnd()*number);  
	if (!result)result++;  
        return result  
};  
var color_cnt5 = 3;  
var color5 = rand(color_cnt5);  
var link5;  
var colorCode5;  
var width5  
var height5  
if (color5==1) {  
colorCode5="#FF0000";  
}  
if (color5==2) {  
colorCode5="#0000FF";  
}  
if (color5==3) {  
colorCode5="#00FF00";  
}  
document.getElementById('cr').innerHTML=(colorCode5);  
// End -->  
</SCRIPT>  
  
<form>  
  <input type="button" value="Refresh" name="refresh" onclick="window.location.reload();"></p>  
</form>  
  
</body>  
  
</html>  

_________________
I don't even know enough to know that i don't know.
View profile  Send private message
negociant

Posts: 31
Posted: 04/07/2007, 5:00 AM

It's NOT JAVA SCRIPT forum and NOT PURE JAVA FORUM.
It's java with CodeChargeStudio forum.
Where in your question JAVA or CODE CHARGE STUDIO???
View profile  Send private message
fady005


Posts: 115
Posted: 04/13/2007, 12:48 AM

Negociant is right... this is not the best place to post an issue about JavaScript... why not in General/Other forum : http://forums.codecharge.com/forum.php?forum_id=2
I would advice you to debug your code using alert function... and maybe use random()%x instead of rnd.seed. I think it's easier to manipulate...

_________________
Be inventive !
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.