I have a multiple choice quiz where I would like to use CSS to change the
color of the answers upon clicking them. I would like to present the right
and wrong answers up front, rather than direct the user to a separate page
with all correct answers.
Do the answers have to be "links" for this to work? They have to be inactive
links, because they don't actually go anywhere. They only serve the purpose
of changing color whether they're right or wrong.
There are four answers per question. Every answer will change a color when
clicked. The correct answer will turn green, and the incorrect one will turn
red. By the end of the quiz, most (if not all) choices will have probably
been clicked.
So, I'm trying to do two things, with a CSS class, if possible:
1) Prevent the clicked text link from trying to take me anywhere
2) Change the color of the text link
How do I do this? Any pointers are appreciated! :-) 11 19494
On Sun, 31 Jul 2005 13:45:18 -0500, Yeah <ye**@positive.net> wrote: I have a multiple choice quiz where I would like to use CSS to change the color of the answers upon clicking them. I would like to present the right and wrong answers up front, rather than direct the user to a separate page with all correct answers.
Do the answers have to be "links" for this to work? They have to be inactive links, because they don't actually go anywhere. They only serve the purpose of changing color whether they're right or wrong.
There are four answers per question. Every answer will change a color when clicked. The correct answer will turn green, and the incorrect one will turn red. By the end of the quiz, most (if not all) choices will have probably been clicked.
So, I'm trying to do two things, with a CSS class, if possible: 1) Prevent the clicked text link from trying to take me anywhere 2) Change the color of the text link
How do I do this? Any pointers are appreciated! :-)
Why use links? If they're not supposed to act like links and the don't take you
anywhere, what's with the choice for links?
I would put the answers in divs with class="answer" and give the right answer an
extra class="answer right". In my stylesheet:
div.answer {
cursor:help; }
div.answer:active {
background-color:red; }
div.right:active {
background-color:green; }
But, hey, _I_ live in a perfect world :-)
^^^^^^^^^^^^^||^^^^^^^^^^^^
||
\/
See <http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes> and note it
says: 'User agents are not required to reflow a currently displayed document due
to pseudo-class transitions.' I bet IE is one of those that feels no obligation
to implement these pseudo classes to any useful extend.
So, In the less perfect real world I would use links in stead of div and with
the above css hope for the best.
--
,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------.
| weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html |
| webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html |
|zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html |
`-------------------------------------------------- --<--@ ------------'
Thanks for the prompt assistance! I have implemented your code and made a
small alteration to the actions for the answers. However, the mouse pointer
changes, but the answers don't change color upon click. In my CSS code, I
have
<Style type="text/css">
<!--
div.answer {cursor: pointer}
div.answer wrong:active {color: red}
div.answer right:active {color: green}
//-->
</Style>
In the actual quiz location in the document, I have this code:
<B>Where is our ridiculously huge store located?</B><BR>
<DD><DIV class="answer wrong">a. Providence, RI</DIV>
<DD><DIV class="answer right">b. Topeka, KS</DIV>
<DD><DIV class="answer wrong">c. Honolulu, HI</DIV>
<DD><DIV class="answer wrong">d. Death Valley, CA</DIV>
My experience with pseudo-classes is limited. Can you help me out a bit
further? :-)
"Barbara de Zoete" <b_********@hotmail.com> wrote in message
news:opsuskr8aix5vgts@zoete_b... On Sun, 31 Jul 2005 13:45:18 -0500, Yeah <ye**@positive.net> wrote:
I have a multiple choice quiz where I would like to use CSS to change the color of the answers upon clicking them. I would like to present the right and wrong answers up front, rather than direct the user to a separate page with all correct answers.
Do the answers have to be "links" for this to work? They have to be inactive links, because they don't actually go anywhere. They only serve the purpose of changing color whether they're right or wrong.
There are four answers per question. Every answer will change a color when clicked. The correct answer will turn green, and the incorrect one will turn red. By the end of the quiz, most (if not all) choices will have probably been clicked.
So, I'm trying to do two things, with a CSS class, if possible: 1) Prevent the clicked text link from trying to take me anywhere 2) Change the color of the text link
How do I do this? Any pointers are appreciated! :-)
Why use links? If they're not supposed to act like links and the don't take you anywhere, what's with the choice for links?
I would put the answers in divs with class="answer" and give the right answer an extra class="answer right". In my stylesheet:
div.answer { cursor:help; }
div.answer:active { background-color:red; }
div.right:active { background-color:green; }
But, hey, _I_ live in a perfect world :-) ^^^^^^^^^^^^^||^^^^^^^^^^^^ || \/
See <http://www.w3.org/TR/CSS2/selector.html#dynamic-pseudo-classes> and note it says: 'User agents are not required to reflow a currently displayed document due to pseudo-class transitions.' I bet IE is one of those that feels no obligation to implement these pseudo classes to any useful extend.
So, In the less perfect real world I would use links in stead of div and with the above css hope for the best. -- ,-- --<--@ -- PretLetters: 'woest wyf', met vele interesses: ----------. | weblog | http://home.wanadoo.nl/b.de.zoete/_private/weblog.html | | webontwerp | http://home.wanadoo.nl/b.de.zoete/html/webontwerp.html | |zweefvliegen | http://home.wanadoo.nl/b.de.zoete/html/vliegen.html | `-------------------------------------------------- --<--@ ------------'
Yeah wrote: Thanks for the prompt assistance! I have implemented your code and made a small alteration to the actions for the answers. However, the mouse pointer changes, but the answers don't change color upon click. In my CSS code, I have
<Style type="text/css"> <!-- div.answer {cursor: pointer} div.answer wrong:active {color: red} div.answer right:active {color: green} //--> </Style>
In the actual quiz location in the document, I have this code:
<B>Where is our ridiculously huge store located?</B><BR> <DD><DIV class="answer wrong">a. Providence, RI</DIV> <DD><DIV class="answer right">b. Topeka, KS</DIV> <DD><DIV class="answer wrong">c. Honolulu, HI</DIV> <DD><DIV class="answer wrong">d. Death Valley, CA</DIV>
My experience with pseudo-classes is limited. Can you help me out a bit further? :-)
You may find a combination of CSS and JavaScript will do the job:
<head>
<title>Answer play</title>
<script type="text/javascript">
function addClass( el, c ){
var re = new RegExp('\b' + c + '\b');
if ( el.className && !re.test( el.className ) ){
el.className += ' ' + c;
}
}
</script>
<style type="text/css">
.answer {cursor: pointer}
.wrong {color: red}
.right {color: green}
</style>
</head><body>
<b>Where is our ridiculously huge store located?</B><BR>
<dd><div class="answer" onclick="
addClass(this, 'wrong');
">a. Providence, RI</div>
<dd><div class="answer" onclick="
addClass(this, 'right');
">b. Topeka, KS</div>
<dd><div class="answer" onclick="
addClass(this, 'wrong');
">c. Honolulu, HI</div>
<dd><div class="answer" onclick="
addClass(this, 'wrong');
">d. Death Valley, CA</div>
</body>
[...]
--
Rob
RobG,
Thanks for the code! It worked. Now the only thing I'm left to wonder is if
XP SP2's Internet Explorer security alerts (for JavaScript) will interfere
with this...
--
- Dave www.grundage.com
"RobG" <rg***@iinet.net.auau> wrote in message
news:Sw***************@news.optus.net.au... Yeah wrote: Thanks for the prompt assistance! I have implemented your code and made a small alteration to the actions for the answers. However, the mouse pointer changes, but the answers don't change color upon click. In my CSS code, I have
<Style type="text/css"> <!-- div.answer {cursor: pointer} div.answer wrong:active {color: red} div.answer right:active {color: green} //--> </Style>
In the actual quiz location in the document, I have this code:
<B>Where is our ridiculously huge store located?</B><BR> <DD><DIV class="answer wrong">a. Providence, RI</DIV> <DD><DIV class="answer right">b. Topeka, KS</DIV> <DD><DIV class="answer wrong">c. Honolulu, HI</DIV> <DD><DIV class="answer wrong">d. Death Valley, CA</DIV>
My experience with pseudo-classes is limited. Can you help me out a bit further? :-)
You may find a combination of CSS and JavaScript will do the job:
<head> <title>Answer play</title> <script type="text/javascript"> function addClass( el, c ){ var re = new RegExp('\b' + c + '\b'); if ( el.className && !re.test( el.className ) ){ el.className += ' ' + c; } } </script>
<style type="text/css"> .answer {cursor: pointer} .wrong {color: red} .right {color: green} </style> </head><body> <b>Where is our ridiculously huge store located?</B><BR> <dd><div class="answer" onclick=" addClass(this, 'wrong'); ">a. Providence, RI</div> <dd><div class="answer" onclick=" addClass(this, 'right'); ">b. Topeka, KS</div> <dd><div class="answer" onclick=" addClass(this, 'wrong'); ">c. Honolulu, HI</div> <dd><div class="answer" onclick=" addClass(this, 'wrong'); ">d. Death Valley, CA</div>
</body>
[...]
-- Rob
Yeah schreef: Thanks for the prompt assistance! I have implemented your code and made a small alteration to the actions for the answers. However, the mouse pointer changes, but the answers don't change color upon click. In my CSS code, I have
<Style type="text/css"> <!-- div.answer {cursor: pointer} div.answer wrong:active {color: red} div.answer right:active {color: green} //--> </Style>
In the actual quiz location in the document, I have this code:
<B>Where is our ridiculously huge store located?</B><BR> <DD><DIV class="answer wrong">a. Providence, RI</DIV> <DD><DIV class="answer right">b. Topeka, KS</DIV> <DD><DIV class="answer wrong">c. Honolulu, HI</DIV> <DD><DIV class="answer wrong">d. Death Valley, CA</DIV>
My experience with pseudo-classes is limited. Can you help me out a bit further? :-)
It should be
div.wrong:active {color: red}
div.right:active {color: green}
and then it works (in Firefox, but not in Explorer; Explorer doesn't do
:active or :hover on anything but links).
HTH,
Berna
--
( )_( ) Berna M. Bleeker-Slikker
/ . . \ be***********@gmail.com
\ \@/ / http://www.volksliedjes.nl
The idea for my multiple choice quiz was to have the corect answer change
color on hover, but when clicked, not have it do anything. But it uses CSS
and JavaScript in conjunction, which seems too busy for me.
I've thought of a different way of showing answers for my quiz. I'm
reluctant about getting JavaScript involved, because users with Windows SP2
will be getting script warnings if using IE. I'm not sure I want to mess
with that.
I was thinking of having a blank colored space beside each question
(background-color: yellow, color: black). It's NOT an A HREF, and it's not
clickable. When the user hovers over it, the blank space reveals the answer
(colored black).
Can I have non-hyperlinked text change color on hover? Do I have to have a
class (.) to enable hovering effects, or can it be an ID (#)?
Further ideas are appreciated. Thanks!
"Yeah" <ye**@positive.net> wrote in message
news:U_8He.28588$mC.8438@okepread07... I have a multiple choice quiz where I would like to use CSS to change the color of the answers upon clicking them. I would like to present the right and wrong answers up front, rather than direct the user to a separate page with all correct answers.
Do the answers have to be "links" for this to work? They have to be inactive links, because they don't actually go anywhere. They only serve the purpose of changing color whether they're right or wrong.
There are four answers per question. Every answer will change a color when clicked. The correct answer will turn green, and the incorrect one will turn red. By the end of the quiz, most (if not all) choices will have probably been clicked.
So, I'm trying to do two things, with a CSS class, if possible: 1) Prevent the clicked text link from trying to take me anywhere 2) Change the color of the text link
How do I do this? Any pointers are appreciated! :-)
On Sun, 7 Aug 2005 16:18:48 -0500, "Yeah" <ye**@positive.net> wrote: The idea for my multiple choice quiz was to have the corect answer change color on hover, but when clicked, not have it do anything. But it uses CSS and JavaScript in conjunction, which seems too busy for me.
I've thought of a different way of showing answers for my quiz. I'm reluctant about getting JavaScript involved, because users with Windows SP2 will be getting script warnings if using IE. I'm not sure I want to mess with that.
I was thinking of having a blank colored space beside each question (background-color: yellow, color: black). It's NOT an A HREF, and it's not clickable. When the user hovers over it, the blank space reveals the answer (colored black).
Can I have non-hyperlinked text change color on hover? Do I have to have a class (.) to enable hovering effects, or can it be an ID (#)?
Further ideas are appreciated. Thanks!
This might for you: just make the answer text the same color
as the background. Invisible until *highlighted* by a sweep of
the mouse (not hover and not click). I know of a quiz that uses
this method. (The viewer may need a few words of instruction.)
Mason C
Mason A. Clark schreef: On Sun, 7 Aug 2005 16:18:48 -0500, "Yeah" <ye**@positive.net> wrote:
The idea for my multiple choice quiz was to have the corect answer change color on hover, but when clicked, not have it do anything. But it uses CSS and JavaScript in conjunction, which seems too busy for me.
I've thought of a different way of showing answers for my quiz. I'm reluctant about getting JavaScript involved, because users with Windows SP2 will be getting script warnings if using IE. I'm not sure I want to mess with that.
I was thinking of having a blank colored space beside each question (background-color: yellow, color: black). It's NOT an A HREF, and it's not clickable. When the user hovers over it, the blank space reveals the answer (colored black).
Can I have non-hyperlinked text change color on hover? Do I have to have a class (.) to enable hovering effects, or can it be an ID (#)?
Further ideas are appreciated. Thanks!
This might for you: just make the answer text the same color as the background. Invisible until *highlighted* by a sweep of the mouse (not hover and not click). I know of a quiz that uses this method. (The viewer may need a few words of instruction.)
Another idea is just to make the answers a 'link', and give the correct
answer a differents color via a CSS class:
a.correct:hover { background-color: lime}
a.wrong:hover { background-color:red }
<a class="wrong" href="#">Wrong answer</a>
<a class="wrong" href="#">Another wrong answer</a>
<a class="correct" href="#">Correct answer</a>
In other browsers, Firefox for example, :hover works with any element,
but not in IE, so it has to 'a href="[something]"', or Explorer won't
highlight it. The "#" part is so you don't get a message about a missing
file when you click on it; but it doesn't refer to any location so you
don't jump around in the document either.
It should work with IDs just as well as with classes, but an ID can only
occur once per page, and you can add the 'correct' class to all right
answers, and the 'wrong' class to all wrong answers.
HTH,
Berna
--
( )_( ) Berna M. Bleeker-Slikker
/ . . \ be***********@gmail.com
\ \@/ / http://www.volksliedjes.nl
But doesn't HREFing to a # jump you to the top of the page? That's another
thing I'm trying to avoid. I've considered either having the user click the
correct answer, or mouseover a selection of invisible text to reveal the
answer, whichever method is simpler...
"Berna Bleeker" <be***********@gmail.com> wrote in message
news:42***********************@news.xs4all.nl... Mason A. Clark schreef: On Sun, 7 Aug 2005 16:18:48 -0500, "Yeah" <ye**@positive.net> wrote:
The idea for my multiple choice quiz was to have the corect answer change color on hover, but when clicked, not have it do anything. But it uses CSS and JavaScript in conjunction, which seems too busy for me.
I've thought of a different way of showing answers for my quiz. I'm reluctant about getting JavaScript involved, because users with Windows SP2 will be getting script warnings if using IE. I'm not sure I want to mess with that.
I was thinking of having a blank colored space beside each question (background-color: yellow, color: black). It's NOT an A HREF, and it's not clickable. When the user hovers over it, the blank space reveals the answer (colored black).
Can I have non-hyperlinked text change color on hover? Do I have to have a class (.) to enable hovering effects, or can it be an ID (#)?
Further ideas are appreciated. Thanks!
This might for you: just make the answer text the same color as the background. Invisible until *highlighted* by a sweep of the mouse (not hover and not click). I know of a quiz that uses this method. (The viewer may need a few words of instruction.)
Another idea is just to make the answers a 'link', and give the correct answer a differents color via a CSS class: a.correct:hover { background-color: lime} a.wrong:hover { background-color:red }
<a class="wrong" href="#">Wrong answer</a> <a class="wrong" href="#">Another wrong answer</a> <a class="correct" href="#">Correct answer</a>
In other browsers, Firefox for example, :hover works with any element, but not in IE, so it has to 'a href="[something]"', or Explorer won't highlight it. The "#" part is so you don't get a message about a missing file when you click on it; but it doesn't refer to any location so you don't jump around in the document either.
It should work with IDs just as well as with classes, but an ID can only occur once per page, and you can add the 'correct' class to all right answers, and the 'wrong' class to all wrong answers.
HTH,
Berna
-- ( )_( ) Berna M. Bleeker-Slikker / . . \ be***********@gmail.com \ \@/ / http://www.volksliedjes.nl
Yeah schreef: But doesn't HREFing to a # jump you to the top of the page? That's another thing I'm trying to avoid. I've considered either having the user click the correct answer, or mouseover a selection of invisible text to reveal the answer, whichever method is simpler...
Oops, you're right! I hadn't noticed that, because I tried it with a
very short page. Then how about this?
<html>
<head>
<title>Just a test</title>
<style type="text/css">
a { color: black; text-decoration: none; }
a.correct:hover { background-color: lime }
a.wrong:hover { background-color: red; color: white }
</style>
</head>
<body>
<p><a name="#question"></a><b>Will your answer to this question be
'No'?</b><br>
a. <a class="wrong" href="#question">No</a><br />
b. <a class="wrong" href="#question">Yes</a><br />
c. <a class="correct" href="#question">I can't answer that question!</a>
</p>
</body>
</html>
That works, if you don't mind the jump to the question (in IE; FF stays
put, as long as the question is in view) when you click on the link.
Berna
--
( )_( ) Berna M. Bleeker-Slikker
/ . . \ be***********@gmail.com
\ \@/ / http://www.volksliedjes.nl This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Andrew DeFaria |
last post by:
I thought this would be fairly straight forward but apparently it's not.
Given the following html file:
<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>...
|
by: manokumar |
last post by:
hiye, i notice that some if not all of my folders in winxp
pro. are set as read only and its giving me some problem
with development. so as the natural thing, i unchecked the
read only option and...
|
by: Tom |
last post by:
I am writing a Visual basic .Net database application.
There are many forms that first let you select and look at
a DB record and then when you click a "modify" button you
are allowed to change...
|
by: Karl |
last post by:
Hi,
Ok so on a given page I have 4 text links:
see it in black
see it in blue
see it in red
see it in green
using the standard swap image behavior, clicking on one of the above links
|
by: Sankalp |
last post by:
Hi,
I am using VB 2005. My application has many data bound controls. The
connection is stored in the app.config file.
I want the application to start with a default connection string and
while...
|
by: sueian |
last post by:
can some1 help with this code.
can i add in a function like on click. when user click one of the link. the color will change to static from mouse over color. the text need to highligted after click....
|
by: mlwerth |
last post by:
Dear Access Group:
This is the most basic and most embarrassing of questions, but I
cannot find where to change the data type of a text field that I have
in Access 2003 to a number field. I've...
|
by: wizdom |
last post by:
Help - change text on click - text has another onclick inside with php variables
----------
I think what I'm trying to do is simple.
I have a 2 buttons on a page. 1 button allows a thread of...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
|
by: Aliciasmith |
last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
|
by: tracyyun |
last post by:
Hello everyone,
I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
|
by: Teri B |
last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course.
0ne-to-many. One course many roles.
Then I created a report based on the Course form and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM)
Please note that the UK and Europe revert to winter time on...
|
by: nia12 |
last post by:
Hi there,
I am very new to Access so apologies if any of this is obvious/not clear.
I am creating a data collection tool for health care employees to complete. It consists of a number of...
|
by: NeoPa |
last post by:
Introduction
For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
| |