Jump to content

If Statement


mcmuney

Recommended Posts

I'm used to php, but am in need of a java if statement and not sure about syntax. What I need is something like:

 

if current_user_time > 20:00

then colorA=#000000 and colorB=#00000F

else

colorA=#00000g and colorB=#00000w

 

Then I need to be able to place colorA and B anywhere within the page.

Link to comment
Share on other sites

function preg_replace(array_pattern, array_pattern_replace, my_string){
var new_string = String (my_string);
for (i=0; i<array_pattern.length; i++) {
	var reg_exp= RegExp(array_pattern[i], "gi");
	var val_to_replace = array_pattern_replace[i];
	new_string = new_string.replace (reg_exp, val_to_replace);
	return new_string;
}
}
var time = Date(hours+":"+minutes);
var formatedDate = preg_replace('\:\\','',time);

if (current_user_time > time) {
colorA='#000000';
colorB='#00000F';
}
else{
colorA='#00000g';
colorB='#00000w';
}

 

or simplest way

 

var time = Date(hours+""+minutes);
if (current_user_time > time) {
colorA='#000000';
colorB='#00000F';
}
else{
colorA='#00000g';
colorB='#00000w';
}

Link to comment
Share on other sites

1) Now when I place "colorA" in a table, for example: <table bgcolor=colorA>, how do I do that? I know if php, I simply place <?=$colorA;?>, what's the equivalent in java?

 

2) What format does "current_user_time" need to be? For example, what would be the format for 9:00PM?

Link to comment
Share on other sites

the time will be hard coded...

 

<html>
<head>
<script type="text/javascript">
var time = Date(hours+""+minutes);
if (current_user_time == 2100) {
colorA='#000000';
colorB='#00000F';
document.getElementById('body').style.bgcolor=colorA;
}
else{
colorA='#00000g';
colorB='#00000w';
}
</script>
<body id="body">
</body>
</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.