Thank you for being a valued part of the CNET community. As of December 1, 2020, the forums are in read-only format. In early 2021, CNET Forums will no longer be available. We are grateful for the participation and advice you have provided to one another over the years.

Thanks,

CNET Support

General discussion

How can I get this form to work?

Jun 10, 2008 2:56PM PDT

I ve found this Javascript question form,from this site;
http://www.shane.co.jp/courses/p_test/pre_que.html
Ive copied the form and intend to change the values with my own subjects for school.Question is how do i get
the button at the bottom to tally up the scores?
How do i get it to work?
Or is there somewhere I can acquire such a form
THANKS
The script is as below;
<form>
<fieldset>
<legend>英会話のレベルチェック 準中 級</legend>
<!--====[Column]====-->

<div class="column" id="pre01">
<h3>1) "How many times have you been to China?" "_____."</h3>
<ul>
<li><input type="radio" name="answer1" value="1" id="a01-1" /><label for="a01-1">One times.</label></li>
<li><input type="radio" name="answer1" value="2" id="a01-2" /><label for="a01-2">Twice.</label></li>
<li><input type="radio" name="answer1" value="3" id="a01-3" /><label for="a01-3">Twice times.</label></li>
<li><input type="radio" name="answer1" value="4" id="a01-4" /><label for="a01-4">Only one.</label></li>

</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->
<div class="column" id="pre02">
<h3>2) _____ you ever been to Paris?</h3>
<ul>
<li><input type="radio" name="answer2" value="1" id="a02-1" /><label for="a02-1">Did</label></li>

<li><input type="radio" name="answer2" value="2" id="a02-2" /><label for="a02-2">Have</label></li>
<li><input type="radio" name="answer2" value="3" id="a02-3" /><label for="a02-3">Do</label></li>
<li><input type="radio" name="answer2" value="4" id="a02-4" /><label for="a02-4">Has</label></li>
</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->

<div class="column" id="pre03">
<h3>3) I _____ my sister since last week.</h3>
<ul>
<li><input type="radio" name="answer3" value="1" id="a03-1" /><label for="a03-1">aren't seeing</label></li>
<li><input type="radio" name="answer3" value="2" id="a03-2" /><label for="a03-2">don't see</label></li>
<li><input type="radio" name="answer3" value="3" id="a03-3" /><label for="a03-3">didn't see</label></li>
<li><input type="radio" name="answer3" value="4" id="a03-4" /><label for="a03-4">haven't seen</label></li>

</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->
<div class="column" id="pre04">
<h3>4) "What about pizza?" "I'd rather ______ a sandwich."</h3>
<ul>
<li><input type="radio" name="answer4" value="1" id="a04-1" /><label for="a04-1">to have</label></li>

<li><input type="radio" name="answer4" value="2" id="a04-2" /><label for="a04-2">have to</label></li>
<li><input type="radio" name="answer4" value="3" id="a04-3" /><label for="a04-3">having</label></li>
<li><input type="radio" name="answer4" value="4" id="a04-4" /><label for="a04-4">have</label></li>
</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->

<div class="column" id="pre05">
<h3>5) "What are your plans tomorrow?"</h3>
<ul>
<li><input type="radio" name="answer5" value="1" id="a05-1" /><label for="a05-1">" I'm going to the office."</label></li>
<li><input type="radio" name="answer5" value="2" id="a05-2" /><label for="a05-2">" I went to the office."</label></li>
<li><input type="radio" name="answer5" value="3" id="a05-3" /><label for="a05-3">" I go to the office."</label></li>
<li><input type="radio" name="answer5" value="4" id="a05-4" /><label for="a05-4">" I shall going to the office."</label></li>

</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->
<div class="column" id="pre06">
<h3>6) Choose the correct sentence.</h3>
<ul>
<li><input type="radio" name="answer6" value="1" id="a06-1" /><label for="a06-1">If I were you I will study hard.</label></li>

<li><input type="radio" name="answer6" value="2" id="a06-2" /><label for="a06-2">If I were you I'd study hard.</label></li>
<li><input type="radio" name="answer6" value="3" id="a06-3" /><label for="a06-3">If I am you I'll study hard.</label></li>
<li><input type="radio" name="answer6" value="4" id="a06-4" /><label for="a06-4">I'd study hard if I'll you.</label></li>
</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->

<div class="column" id="pre07">
<h3>7) Do you _____ to go and see him in the hospital?</h3>
<ul>
<li><input type="radio" name="answer7" value="1" id="a07-1" /><label for="a07-1">must</label></li>
<li><input type="radio" name="answer7" value="2" id="a07-2" /><label for="a07-2">should</label></li>
<li><input type="radio" name="answer7" value="3" id="a07-3" /><label for="a07-3">have</label></li>
<li><input type="radio" name="answer7" value="4" id="a07-4" /><label for="a07-4">will</label></li>

</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->
<div class="column" id="pre08">
<h3>Cool Madonna is the singer _____ sang "Holiday."</h3>
<ul>
<li><input type="radio" name="answer8" value="1" id="a08-1" /><label for="a08-1">who's</label></li>

<li><input type="radio" name="answer8" value="2" id="a08-2" /><label for="a08-2">where</label></li>
<li><input type="radio" name="answer8" value="3" id="a08-3" /><label for="a08-3">whose</label></li>
<li><input type="radio" name="answer8" value="4" id="a08-4" /><label for="a08-4">who</label></li>
</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->

<div class="column" id="pre09">
<h3>9) I'd prefer one _____ has a handle.</h3>
<ul>
<li><input type="radio" name="answer9" value="1" id="a09-1" /><label for="a09-1">who</label></li>
<li><input type="radio" name="answer9" value="2" id="a09-2" /><label for="a09-2">which</label></li>
<li><input type="radio" name="answer9" value="3" id="a09-3" /><label for="a09-3">witch</label></li>
<li><input type="radio" name="answer9" value="4" id="a09-4" /><label for="a09-4">where</label></li>

</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->
<div class="column" id="pre10">
<h3>10) Choose the correct sentence.</h3>
<ul>
<li><input type="radio" name="answer10" value="1" id="a10-1" /><label for="a10-1">I've seen just Chris.</label></li>

<li><input type="radio" name="answer10" value="2" id="a10-2" /><label for="a10-2">I've Chris just seen.</label></li>
<li><input type="radio" name="answer10" value="3" id="a10-3" /><label for="a10-3">I just have seen Chris.</label></li>
<li><input type="radio" name="answer10" value="4" id="a10-4" /><label for="a10-4">I've just seen Chris.</label></li>
</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->

<div class="column" id="pre11">
<h3>11) "What did he say?"</h3>
<ul>
<li><input type="radio" name="answer11" value="1" id="a11-1" /><label for="a11-1">" He me told that he really liked you."</label></li>
<li><input type="radio" name="answer11" value="2" id="a11-2" /><label for="a11-2">" He told me that he really like you."</label></li>
<li><input type="radio" name="answer11" value="3" id="a11-3" /><label for="a11-3">" He told me that he really liked you."</label></li>
<li><input type="radio" name="answer11" value="4" id="a11-4" /><label for="a11-4">" He told me that he has really liked you."</label></li>

</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->
<div class="column" id="pre12">
<h3>12) Don't wait, I _____ late.</h3>
<ul>
<li><input type="radio" name="answer12" value="1" id="a12-1" /><label for="a12-1">can</label></li>

<li><input type="radio" name="answer12" value="2" id="a12-2" /><label for="a12-2">might to be</label></li>
<li><input type="radio" name="answer12" value="3" id="a12-3" /><label for="a12-3">can't be</label></li>
<li><input type="radio" name="answer12" value="4" id="a12-4" /><label for="a12-4">could be</label></li>
</ul>
</div>
<!--====[//Column]====-->
<!--====[Column]====-->

<div class="column" id="pre13">
<h3>13) Well it's nine o'clock, he _____ running late.</h3>
<ul>
<li><input type="radio" name="answer13" value="1" id="a13-1" /><label for="a13-1">could</label></li>
<li><input type="radio" name="answer13" value="2" id="a13-2" /><label for="a13-2">must</label></li>
<li><input type="radio" name="answer13" value="3" id="a13-3" /><label for="a13-3">must be</label></li>
<li><input type="radio" name="answer13" value="4" id="a13-4" /><label for="a13-4">must to be</label></li>

</ul>
</div>
<!--====[//Column]====-->
<input type="button" value="採点する" onclick="checkAnswers()" name="button" />
</fieldset>
</form>

Discussion is locked

- Collapse -
Not Javascript, it's XML
Jun 25, 2008 3:22PM PDT

Find a Javascript like the one you want on the net. Then try it again. The XML may not be running in the application your using because it's XML. If you need Java you'll need to find a Javascript.

- Collapse -
Not xml either.
Jun 29, 2008 12:23AM PDT

It's not javascript, it's not xml. It's plain old html, and it runs in any browser.

And it's a common misunderstanding (with laymen like Dango) that you would need java to run javascripts in your page. You don't. Javascript comes with any browser.

The usual thing you can do with a form is to send the replies to your server, where you can have a program to collect the entries in your database. Or to email them, but that has become impractical with everybody using webmail.
So, to see the results on the screen (only) you'll need to write some script (javascript) to do it. Find something readymade, find a programmer or start programming yourself.
Or go and search for a freeware quiz program.

Kees

- Collapse -
XML document
Jun 29, 2008 5:23AM PDT
- Collapse -
That's a totally irrelevant post.
Jun 29, 2008 7:11AM PDT

It's true. But it's irrelevant also. Remarks about xml are irrelevant here, because that isn't the subject nor the contents of this discussion.
It makes as little sense here as a remark about the Germany-Spain match that was won by Spain half an hour ago, or the carbon dioxide content of the atmosphere in Wien, where it was played.

Kees

- Collapse -
What?
Jun 29, 2008 2:37PM PDT

XML is script. I said nothing about Germany-Spain, as you wish Kees. Are you getting tired?

- Collapse -
XML is no script. XML is XML.
Jun 29, 2008 9:11PM PDT

Extensible Markup Language. Not a language, in fact, more a grammar. But certainly not a scripting language like javascript or vbscript. And not the same as html either.

Kees

- Collapse -
Um...
Jul 3, 2008 9:50AM PDT

Dango,

You have made quite a few errors when trying to give advice. First, JavaScript and Java are two different things. The next is, Kees is right, XML is not a script, it is markup language. You might want to go to http://w3schools.com/ and learn some things before you try and give advice again. Just a thought.

DocGSXR

- Collapse -
Hopefully this will help
Jul 3, 2008 9:46AM PDT

This is for the OP,

Here is the thing, what you posted is only part of the package so to speak. You were asking how do you get the button to function. Well that is where the scripting language is going to come into play. The web page you referenced uses javascript to give the button its functionality. You pasted the html form but forgot to include the javascript that makes it work. After the last question there is a line that reads

<input type="button" value="採点する" onclick="checkAnswers()" name="button" />

This will setup the button and give it functionality on the page that you referenced, by calling a function called checkAnswers(). This function is created using javascript in the <head> of the page.

You will need <script language="JavaScript"> then will need to create the function called checkAnswers().

You can look at how he created his or you can read a book / find some code on the net that will help you create the functionality that you desire. I recommend grabbing a book or going to http://w3schools.com/ for some help.

DocGSXR

- Collapse -
Thanks
Jul 3, 2008 10:55AM PDT

I guess I made a mistake about this being a Javascript.
The other issue was that I have no idea of how to get the form button
to work,that is tally the scores.DocGSXR thanks for that insight.Im still lost at the moment but lemme try and follow your advice.

- Collapse -
I wouldn't be too quick to thank them
Jul 3, 2008 5:03PM PDT

neither has presented you with a solution.

- Collapse -
Indeed.
Jul 3, 2008 5:37PM PDT

It's not customary here for posters to write complete code for the OP. But don't hesitate to do so, if you feel like it.

It has to be a javascript functie checkAnswers, that checks the answers given and displays a total score somewhere on the screen (that must be a part of the screen not shown here). So one needs some knowledge of javascript to make it.

I happened to be doing some javascript at my work the last 2 days. It's rather error-prone work, and I don't feel like doing it for the OP. The best he can do: start from the script that's already be written on the site he cites and adapt that. Like web-pages, scripts are easy to copy.

Kees

Kees

- Collapse -
Yep but
Jul 3, 2008 10:19PM PDT

it's copyrighted material. Reverse engineering is also a no-no. This site might be used as a basic guide however in creating a new one program. If the final product is for sale the post originator might wish to look for a similar open source program on line and avoid this one all together or permissions might be sought. The basic functions here are rather primitive so an alternative should be available on line.

From Kees previous post:

"start from the script that's already be written on the site he cites and adapt that."

- Collapse -
Yeh
Jul 4, 2008 1:37PM PDT

Honestly Im interested in that form coz Ive not seen any other like that one as far as Ive looked.Two, Id like to design one for my own school stuff that looks similar to it.Its to do with tests.Its not for
any financial gain.
Ive really brainstormed on how to get that form button working,for about 2 months now!Mmmmghhmmmm but not ready to give up yet.....

- Collapse -
If you really want something done. You have to do something..
Jul 4, 2008 4:43PM PDT

.. Work! So start digging. There are lots of sources out there but you have to put in the time. In the process you'll undoubtedly learn something even if you fail. No way around it. : D