473,320 Members | 1,814 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Please how to use radio buttons not Select

Hi,
there used to be a simple javascript quiz builder in builder.com, with
which I made the page whose code is given below.
I would like to tweak this so that there are only three (not 4) answer
options, and that they are presented alongside radio buttons (not in a
selectable list). I would be grateful if someone knows how to do this
for me. It would be nice if the student doing the quiz selects the
right answer with the radio button, then clicks a button (that I could
jazz up with a css style) that results in that answer being displayed
either in a single-line text area, or on the surface of another
button, perhaps like "Empty - Correct, well done!"

I don't know what the options are for the outputting of the answer -
can a text area (such as the code currently has) be styled with css
just as a button can be? I assume that in basic html the javascript
can't actively insert the answer with feedback into the html page into
which the quiz code was inserted...??

<html>
<head>
<title>Quiz</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1">
<meta name="description" content="A quiz for students">
<script language="JavaScript">
<!--

var numQues = 1;

var answers = new Array(1);
answers[0] = "empty";

function getScore(form) {
var score = 0;
var currElt;
var currSelection;

for (i=0; i<numQues; i++) {
currElt = form.elements[i];
currSelection = currElt.selectedIndex;
if (currElt.options[currSelection].value == answers[i]) {
score++;
}
}

score = Math.round(score/numQues*100);
form.percentage.value = score + "%";

var correctAnswers = "";
for (i=1; i<=numQues; i++) {
correctAnswers += i + ". " + answers[i-1] + "\r\n";
}
form.solutions.value = correctAnswers;

}

// -->
</script>

</head>

<body>
<form name="quiz">

<select name="q1">
<option value="">Choose word...
<option value="hungry">hungry
<option value="empty">empty
<option value="late">late
<option value="sad">sad
</select>
<p>

<input type="button" value="Get score" onClick="getScore(this.form)">
<input type="reset" value="Clear">
<p> <font face="Comic Sans MS">Score / <font
color="#993300">Ergebnis</font>
=</font>
<input type=text size=15 name="percentage"><br>
<font face="Comic Sans MS">Correct answer / <font
color="#993300">Richtige
Antwort</font>:</font><br>
<textarea name="solutions" wrap="virtual" rows="4"
cols="40"></textarea>
</form>

</body>
</html>

Thanks,
Dave
Jul 20 '05 #1
1 3410
Dave wrote:
Hi,
there used to be a simple javascript quiz builder in builder.com, with
which I made the page whose code is given below.
I would like to tweak this so that there are only three (not 4) answer
options, and that they are presented alongside radio buttons (not in a
selectable list). I would be grateful if someone knows how to do this
for me. It would be nice if the student doing the quiz selects the
right answer with the radio button, then clicks a button (that I could
jazz up with a css style) that results in that answer being displayed
either in a single-line text area, or on the surface of another
button, perhaps like "Empty - Correct, well done!"

I don't know what the options are for the outputting of the answer -
can a text area (such as the code currently has) be styled with css
just as a button can be? I assume that in basic html the javascript
can't actively insert the answer with feedback into the html page into
which the quiz code was inserted...??


Have you seen this?

http://tech.irt.org/articles/js216/index16.htm

Jul 20 '05 #2

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

Similar topics

3
by: elhombrebala | last post by:
With this script I can force the user to select the checkbox befor continuing, but now I have a menu with lots of radio unputs and I woul like the user to select at least 2 of them; how can I check...
1
by: Rick | last post by:
After being frustrated with this issue on several occasions I think I found the secret sauce for solving the issue after reading a few different messages about what others thought and trying a...
4
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1>...
2
by: jimi_xyz | last post by:
Sorry if this isn't the correct group, i don't think there is a group for straight HTML. I am trying to create a type of search engine. There are two radio buttons at the top, in the middle there...
5
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the...
4
by: Jared | last post by:
Radio Button or Check Box and Event Procedures I need to insert either radio buttons or check boxes onto my form. I'm not sure which to use, or if there are other options. I am using the buttons...
2
by: tshad | last post by:
I have 2 radio buttons: <asp:RadioButton ID="radDetail" GroupName="detailSummary" Text="Detail" checkedChanged="RadDetail_Clicked" runat="server" /> <asp:RadioButton ID="radSummary"...
3
by: Ferret Face | last post by:
Hello, I have a web page that gets the user to select items from a list of options. This list is a set of independant Radio Buttons. I did not use a Radio Button List because I wanted the...
10
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio...
7
by: gengyue | last post by:
Hi, I am running a report using Cold Fusion. This report is generated by cfloop tag. Depends on the record count of a query, the report will list the data retrieved from the database. each row in...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.