Flash Games
 FAQ   Search   Memberlist   Usergroups   Register  Profile   Log in to check your private messages   Log in 


if else statement in java script



 

Post new topic   Reply to topic  
   DEVPPL Forum Index -> JavaScript Forum
View previous topic :: View next topic  
Author Message
msanitanash



Joined: 03 Mar 2008
Posts: 9

PostPosted: Fri Apr 25, 2008 2:31 pm    Post subject: if else statement in java script Reply with quote

I am trying to write a script so that a user can pick the background color but if they chose black I need the text to change to white can someone please help



<script type="text/javascript">
<!-- <![CDATA[
var userColor;
userColor = prompt ("Please type the color that you want the background to be");

if (userColor = black)

{
document.write ("Please select any color except black");


}
else {
document.bgColor = userColor;
}

// }}> -->
</script>
Back to top
View user's profile Send private message
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 560
Location: Cebu City Philippines

PostPosted: Sat Apr 26, 2008 2:19 am    Post subject: Re: if else statement in java script Reply with quote

Maybe this could help you Wink
Code:

<script type="text/javascript">
<!-- <![CDATA[
window.onload = function()
{
var userColor;
userColor = prompt ("Please type the color that you want the background to be","Select Color");

if (userColor == 'black' || userColor=='#000000')
{
//document.write ("Please select any color except black");
document.body.style.background=userColor;
document.body.style.color='#fff';
}
}
// }}> -->
</script>
</head>
<body>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin massa. Nam vehicula.
Morbi velit nisi, mollis id, ultrices luctus, adipiscing sit amet, lectus. Nunc rhoncus
nisl ac enim. Maecenas vestibulum dolor ut velit. Maecenas condimentum pulvinar purus.
Pellentesque ac ipsum. Curabitur sodales, elit vel molestie hendrerit, elit odio rhoncus tellus,
nec gravida enim urna id velit. Donec nec tellus. Vestibulum nulla. Curabitur enim arcu,
ornare id, placerat eget, nonummy vitae, mauris. Nulla rutrum semper odio. Duis vulputate
ornare mauris. Praesent eget nibh sed ante ultricies scelerisque. Duis eget felis ut arcu porta
bibendum. Mauris rutrum. Vivamus consectetuer purus sit amet mi. Suspendisse eu augue.
Quisque nec enim. Nullam elementum. Quisque rhoncus. Ut cursus, pede sit amet facilisis pretium,
est erat congue tortor, eget tincidunt metus augue in mauris. Sed id pede. Nam varius faucibus massa.
In orci. Suspendisse metus nunc, egestas non, porta a, fermentum interdum, mi. Nulla vel tellus nec
erat consectetuer molestie. Vivamus turpis erat, rhoncus sed, ornare vel, volutpat sagittis, nibh.
Nulla libero. Aliquam erat volutpat. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Cum sociis
natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Ut id mauris eget felis laoreet
semper. Maecenas venenatis erat et orci. Aenean interdum ligula sed nisi. Nulla vel lectus eu dolor porttitor
tempus. Proin at nisi fringilla pede feugiat luctus. Aenean id risus. Vestibulum a erat ac ipsum fringilla
feugiat. Cras mauris.
</body>
</html>
Back to top
View user's profile Send private message Yahoo Messenger
pumpkin



Joined: 11 May 2008
Posts: 3

PostPosted: Sun May 11, 2008 6:38 pm    Post subject: if else statement Reply with quote

Hi i'm trying to do a nested if else statement where a bidder enters an amount and if its less han 100 an increment is added to it else it moves on to the next condition. Any help you can give me would be so very much appreciated Confused
Back to top
View user's profile Send private message
rangana
500+ Club


Joined: 27 Feb 2008
Posts: 560
Location: Cebu City Philippines

PostPosted: Tue May 13, 2008 1:17 am    Post subject: Re: if else statement in java script Reply with quote

Hi pumpkin,

First of all, you should'nt be hijacking someone else's thread, I would suggest to create your own, but then, I see that you already did.

Anyway, show us your codes, not here, but on your other thread Smile
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic    DEVPPL Forum Index -> JavaScript Forum All times are GMT + 1 Hour
Page 1 of 1

 
 
Welcome to DEVPPL.com
You are not logged in, which means that you can't post in the forums.
Click here to Register

If you are a current member here on DEVPPL, please login below:

User: Pass:
Log me on automatically each visit:

 


Powered by phpBB © 2001, 2005 phpBB Group - Modified by DEVPPL

Flash Games - Sitemap