Got a little techonology problem that you need fixed pronto? Post it here and we'll see what we can do.
Topic locked

Programming Question

Thu Feb 08, 2007 1:13 am

Ok. My teacher doesn't care how it's done, but he wants me to program a test for him. I was thinking a submit form with right or wrong answers. Any way I do it, is it possible?

Thu Feb 08, 2007 1:32 am

1. What kind of test form?

2. What kind of comp. language

xD

Thu Feb 08, 2007 1:44 am

I don't really know the specifics yet, but I think like maybe multiple choice, fill in the blank,

and if it's possible, html or javascript. I don't want the code, even though it'd be convenient, I just want to know if it's even possible.

Thu Feb 08, 2007 1:51 am

of course it's possible xD what do you think those forms are made out of? eh?

Thu Feb 08, 2007 1:54 am

What do you mean? The programming language?

I can make the forms with HTML.

Thu Feb 08, 2007 2:28 am

So you answered your own question ^^ try and make it now xD

Thu Feb 08, 2007 3:09 am

Yep! A form with a javascript hooked up to it would work well :)

Amongst other things, you'd need something like:

Code:
<form id="form1" onsubmit="checkAnswers()">
   <label for="name">Name:</label>
   <input id="name" name="name" type="text" />
   <input type="submit" name="submit" value="Go!" />
</form>

When this form is submitted (when you press the submit button), it will call a javascript function called "checkAnswers()", and you can do various spiffy calculations there.

For instance, this will take the name that's been inputted in the textfield, and display an alert:
Code:
<script language="javascript" type="text/javascript">
   function checkAnswers()
   {
      var name = document.getElementById("name").value;
      alert("Hello "+name);
   }
</script>


(you can try just copying and pasting those into a webpage... probably in the opposite order though (script and then form)).

The w3schools website has a good section on javascript too, incase you need to read up on it: http://www.w3schools.com/js/default.asp :)

Thu Feb 08, 2007 3:54 am

Thanks for the advice, everybody. I'll try to use it.
Topic locked