The Artima Developer Community
Sponsored Link

Java Answers Forum
Question/Answer Changing Background Colors

1 reply on 1 page. Most recent reply: Aug 10, 2007 12:50 PM by Syed Mudassir Ahmed

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Brook

Posts: 12
Nickname: brook
Registered: Sep, 2002

Question/Answer Changing Background Colors Posted: Aug 8, 2007 12:55 PM
Reply to this message Reply
Advertisement
I have an HTML page I am creating. It will contain a large list of questions to be answered. For here though, I will shorten it for simplicity.

1) The HTML page for this example will have two columns and ten rows. If the User answers the question correctly, then the background color in the answer cell (the rows in the first column) will change to Green. If the answer is wrong, then the background will change to Red.

So are a few examples:
Question 1 is to be True and the User types in T. The background color behind the T now changes to Green.

Question 2 is to be True and the User types in a F. The background color behind the F is to change to Red.

Question 3 is to be False and the User types in a F. The background color behind the F is to change to Green.

Question 4 is to be False and the User types in a T. The beckground color behind the T changes to Red.

As you can see, if the User types in the correct answer, the background color changes to Green. If they type in an incorrect answer, the background color changes to Red.

I do not know alot about Javascript so alot of help on this code is greatly appreciated.

Last, if this is the wrong place to post this question, since it does say Java instead of Javascript, I apologize. Maybe still you could still help.

Thanks.


Syed Mudassir Ahmed

Posts: 2
Nickname: symu0601
Registered: Aug, 2007

Re: Question/Answer Changing Background Colors Posted: Aug 10, 2007 12:50 PM
Reply to this message Reply
Hi Brook.
Well if you can use applets then it will be easy for you to do what you want.
All you have to do is extend the JApplet or Applet class and at the same time implement Runnable interface. When you implement this interface, you should define run() method. In this method, you can put an infinite loop to keep checking the contents of cells(probably textfields). If the cell does not contain any data, ignore it. If it contains data then test if it is T or F. If T, change the color to green and if F, change the color to red.
Well first I am not sure of what kind of applcation you are developing. If this does not help you, feel free to describe me your application requirements. If I can help, I would surely do that.

All the best!!

Flat View: This topic has 1 reply on 1 page
Topic: Question/Answer Changing Background Colors Previous Topic   Next Topic Topic: Server side form validation

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use