473,657 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with a multiple choice quiz.

Hi all,

I have been asked (nay told!) to do a quiz for a webpage at work, now
I can do the basic things like getting the radio boxes up there and
assign values to them but here is what they want:

5 options (done that)

You can only select 2 of the 5 options (dont know how to do that)

click on submit (done that button!)

Depending on which 2 choices they have selected they are shown an few
sentences of relevant text, ie option 1 and 3 will show the text
assigned to each option (dont know how to do this either!)

Does anyone know how to do this? oif not can someone please point me
to a decent website/book?

Many many thanks
Jul 23 '05 #1
4 3808
Dave Parrin-Bull wrote:
Hi all,

I have been asked (nay told!) to do a quiz for a webpage at work, now
I can do the basic things like getting the radio boxes up there and
assign values to them but here is what they want:

5 options (done that)

You can only select 2 of the 5 options (dont know how to do that)

click on submit (done that button!)

Depending on which 2 choices they have selected they are shown an few
sentences of relevant text, ie option 1 and 3 will show the text
assigned to each option (dont know how to do this either!)

Does anyone know how to do this? oif not can someone please point me
to a decent website/book?

Many many thanks

Well, Radio buttons are never meant to be multiply selected. This is
why you cannot choose a MULTIPLE option on a radio group. You can do it
with check boxes, but it can be messy.

Take a look at the following code. It is a good starter for what you
want to do, using radio buttons. It is not close to complete, but it is
useful for a clean code solution. To get this working, you need to
maintain an array of the last two checks for the question. When the
function is called, uncheck the one selected two times ago, and rotate
the data.

You can also use the SELECT box, multiple options, and stop them from
choosing more, but that is not what it sounds like you want.

To dynamically change text, use the SPAN tag, and change the innerText
value for any field you wish to change in the function. For this text,
you will either need to keep another array, or pass it as a function
parameter, or use the VALUE variable in the INPUT checkbox tag.

Will this be sent to a server backend for processing? If so, each
checkbox will show up as a variable. You might want to catch an
onSubmit event, and build up a hidden value string with the final answer
set, based on your checked array.

Hope this helps you get on your way...
Brian

<HTML>

<HEAD>
<SCRIPT type="text/javascript" src="records.js "></SCRIPT>
</HEAD>

<BODY>

<SCRIPT type="text/javascript">

function ac( obj )
{
var info = obj.name.split( "-");
alert("Ques : " + info[0] + " Ans : " + info[1] + " " + obj.checked);
}

</SCRIPT>

<FORM action="submit. asp">
<INPUT TYPE=checkbox name=Q1-A1 onClick="ac(thi s)">Answer 1<BR>
<INPUT TYPE=checkbox name=Q1-A2 onClick="ac(thi s)">Answer 2<BR>
<INPUT TYPE=checkbox name=Q1-A3 onClick="ac(thi s)">Answer 3<BR>
<INPUT TYPE=checkbox name=Q1-A4 onClick="ac(thi s)">Answer 4<BR>
<INPUT TYPE=checkbox name=Q1-A5 onClick="ac(thi s)">Answer 5<BR>
</FORM>
</BODY>
</HTML>
Jul 23 '05 #2
Brian Genisio wrote:

<HEAD>
<SCRIPT type="text/javascript" src="records.js "></SCRIPT>
</HEAD>


Woops... cut this out. It was from a different page that I had modified
slightly. This was not supposed to be there for you.

Brian

Jul 23 '05 #3
Thanks Brian, your help is appreciated and very very useful!

"Brian Genisio" <Br**********@y ahoo.com> wrote in message
news:40******** @10.10.0.241...
Dave Parrin-Bull wrote:
Hi all,

I have been asked (nay told!) to do a quiz for a webpage at work, now
I can do the basic things like getting the radio boxes up there and
assign values to them but here is what they want:

5 options (done that)

You can only select 2 of the 5 options (dont know how to do that)

click on submit (done that button!)

Depending on which 2 choices they have selected they are shown an few
sentences of relevant text, ie option 1 and 3 will show the text
assigned to each option (dont know how to do this either!)

Does anyone know how to do this? oif not can someone please point me
to a decent website/book?

Many many thanks

Well, Radio buttons are never meant to be multiply selected. This is
why you cannot choose a MULTIPLE option on a radio group. You can do it
with check boxes, but it can be messy.

Take a look at the following code. It is a good starter for what you
want to do, using radio buttons. It is not close to complete, but it is
useful for a clean code solution. To get this working, you need to
maintain an array of the last two checks for the question. When the
function is called, uncheck the one selected two times ago, and rotate
the data.

You can also use the SELECT box, multiple options, and stop them from
choosing more, but that is not what it sounds like you want.

To dynamically change text, use the SPAN tag, and change the innerText
value for any field you wish to change in the function. For this text,
you will either need to keep another array, or pass it as a function
parameter, or use the VALUE variable in the INPUT checkbox tag.

Will this be sent to a server backend for processing? If so, each
checkbox will show up as a variable. You might want to catch an
onSubmit event, and build up a hidden value string with the final answer
set, based on your checked array.

Hope this helps you get on your way...
Brian

<HTML>

<HEAD>
<SCRIPT type="text/javascript" src="records.js "></SCRIPT>
</HEAD>

<BODY>

<SCRIPT type="text/javascript">

function ac( obj )
{
var info = obj.name.split( "-");
alert("Ques : " + info[0] + " Ans : " + info[1] + " " + obj.checked);
}

</SCRIPT>

<FORM action="submit. asp">
<INPUT TYPE=checkbox name=Q1-A1 onClick="ac(thi s)">Answer 1<BR>
<INPUT TYPE=checkbox name=Q1-A2 onClick="ac(thi s)">Answer 2<BR>
<INPUT TYPE=checkbox name=Q1-A3 onClick="ac(thi s)">Answer 3<BR>
<INPUT TYPE=checkbox name=Q1-A4 onClick="ac(thi s)">Answer 4<BR>
<INPUT TYPE=checkbox name=Q1-A5 onClick="ac(thi s)">Answer 5<BR>
</FORM>
</BODY>
</HTML>

Jul 23 '05 #4
Dave Parrin-Bull wrote:
Hi all,

I have been asked (nay told!) to do a quiz for a webpage at work, now
I can do the basic things like getting the radio boxes up there and
assign values to them but here is what they want:

5 options (done that)

You can only select 2 of the 5 options (dont know how to do that)

click on submit (done that button!)

Depending on which 2 choices they have selected they are shown an few
sentences of relevant text, ie option 1 and 3 will show the text
assigned to each option (dont know how to do this either!)

Does anyone know how to do this? oif not can someone please point me
to a decent website/book?

Many many thanks

Why reinvent the wheel. There are plenty of quiz scripts out there.
Here is client side solution:
www.klproductions.com/klquiz.html

--
Vladdy
http://www.klproductions.com
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
23537
by: Mohammed Mazid | last post by:
Can anyone please give me some clues on how to track the right answers in multiple-choice type questions (using checkbox) and single-choice questions (rdio buttons) and also how to store the right answer value in the db? Much appreciated
5
5748
by: Vandana Rola | last post by:
Hello Everyone, I am a beginner in Javascript.I want to create fun quiz tool using javascript (no database). The feature of that tool is every question has five choices. The user needs to select three best choices. If they do, a message window pops up which says good choices or something and take them to next question. If they don't choose all of the best choices they get another message like try again but these are not the best choices...
1
5060
by: raiya | last post by:
hi, I'm a teacher and new ms access user. I'm intending to design an ms access db to post multiple choice questions each with 4 choices. I created 2 tables one for the questions and the other for the answers. The first has the fields: question_no - number question - text answer - memo --- gives the full solution The second has the fields: question_no - number answer_no - number answer - text t/f - text --- if this is the correct...
0
1169
by: Night Air | last post by:
I have problem with a website that collects user responses to multiple choice questions. The users choose and value from a Radio Button, then click on a Next button to go the next page. The problem occurs when users click on the Next button too quickly. For example, when you click a few times, in rapid succession, even thought the pages are not displayed between the first and the page you arrive at, the same multiple choice response...
1
2760
by: mcr29 | last post by:
I've been asked to build a survey database. The survey is to be dynamic, allowing any number of questions to be part of the current survey. So I've got a Survey table with SurveyDetail, and a Questions table with a column named 'Active' for that purpose. This makes storing answers a bit difficult. Some are multiple choice, in which case it's as simple as storing an AnswerID in SurveyDetail that links to a Answer table that links to the Question...
7
6661
by: tea-jay | last post by:
hello every body our teacher asks us to write this assiment it has 2 question i did write the first one but the other was really complicated 2 me coz our teacher doesn't know how to explain this so plz plz try to solve this problem
1
6119
by: Brian Byrne | last post by:
Hi , Does anybody know where there is a good bank of C++ multiple choice questions covering all the essentials. I need to brush up on the basics and multiple choice is the ideal way !? Thanks, Brian
3
9019
mb60
by: mb60 | last post by:
hello I am working as teacher. Pl any one can help me in creating a template for multiple choice questions, and matching questions and selecting the answers in ms access? The format of qns as follows 1). xxxxxxxxxxxxxxxxxx 1) aaaaaaaaaaaa 2) bbbbbbbb 3) cccccccccccc 4) dddddddd 2) Match the following List - I List -II A) aaaaa I) bbbbb B) ccccc ...
3
7790
by: shashkun | last post by:
hii i wanted to insert questions, options and correct answer in the database(Multiple choice questions). I have around 8000 questions to be inserted. I tried with copying entire content from word into notepad and provided delimiters for questions and answers but the entire question appears in a single line(it is big problem when question size is big)in the data base which i dont want to be /// Could anyone of you help me out? Note: We can...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.