views:

176

answers:

6

I don't know what I'm talking about. Please tell me what I need to know. ^_^" I would like to create an online test that sends the results to a certain email address, but I'm not sure how to begin. I think it's possible to make textboxes and stuff with both Java and applets, or JavaScript, right? Which should I try working on?

I also want the test to change each time it's ran, most likely based on a .txt or something that tells how to change the questions and answers. I'm not really sure how to make that work yet, either... I guess, using functions to say how to change things based on variables I use in a different file. Can javascript even read stuff from other places? So maybe it needs to be the applet thingy?

A: 

You shouldn't use a Java applet for forms. It's bad for accessibility.

JavaScript can indeed read files from remote locations, such as via Ajax. You should use an Ajax toolkit like http://jquery.com to help you. :-)

Chris Jester-Young
A: 

Make forms with HTML. You can read the .txt file using AJAX and Javascript. (Trying to work out the native AJAX system is messy, though. jQuery has a nice AJAX system for that :D) Alternatively, you can use the back-end system to generate the HTML for the form instead of having Javascript populate it.

Actually processing the forms will require knowledge of a back-end system; neither Java applets nor client-side Javascript will help you here. For a simple script like this, I'd recommend PHP, though it will take some muddling through if you really don't know what you're doing.

Matchu
Good answer, but no upvote because of PHP recommendation. :-P
Chris Jester-Young
PHP's quick to get up and running for something small. For a larger app, I wouldn't recommend it, but it looks like it'll only be handling two or three actions here.
Matchu
A: 

You can create the form with basic HTML. There's a good tutorial on it here. The form must post to a server-side script (the most commong of which is php). That server side script will handle saving the data, emailing it, etc.

Mike Trpcic
+1  A: 

You should probably use HTML + JavaScript for the forms, along with a server-side scripting platform like php, ASP.NET, et al.

Daniel Vassallo
can you explain what a server-side scripting platform is?
Asj
@Asj: I suggest checking out Chris T's answer... The php part in Chris' answer resides on the server.
Daniel Vassallo
A: 

Use HTML & Javascript. There is a nice tutorial for both in here.

SoftwareGeek
+1  A: 

Here's a quick example using HTML + PHP (forgoing javascript for simplicity)

HTML Page (index.html):

<html>
<head>
<title>My Cool Form</title>
</head>
<body>
<!-- Set the action to the page that will handle the form data -->
<form action = "thanks.php" method="post">
<!-- The name attribute will be used by thanks.php later -->
E-Mail: <input name="email" type="text"></input>
<input type="submit" value="Submit"></input>
</form>
</html>

thanks.php:

<?php
$to = "[email protected]"
$from = "From: [email protected]";
$subject = "Got a result from the form!";
// Get the e-mail from the form
$email = $_POST['email'];
$body = "The persons e-mail is" . $email;

// Send an e-mail to [email protected] 
mail($to, $subject, $body, $from);

?>
<html>
<head>
<title>Thank you :)</title>
</head>
<body>
Thanks for your submition. We have added 
<?php 
      echo $email;
?>
to our mailing list!.
</body></html>

HTML is a markup language used to define your document and forms. This is used by your browser to create the webpage seen by your user.

PHP is a server-sided language which runs on your server, not the users, that accesses data such as information from forms, databases, rss feeds, etc and then processes the data (for example mailing the form results to you) before sending the user a HTML document (like one that says thank you for you submition, latest blog posts from a database, etc).

Find a nice free host and upload these files to see them in action.

Chris T
+1 Good answer :)
Daniel Vassallo
I've done a little stuff with JavaScript before but nothing with PHP...What I was thinking about was having a little form for checking username and passwords, and if it checks out, store that info for later and load a larger form. The larger form's content relies on a saved file made with a Java program.I can do that with PHP, right?
Asj
Yes that's very possible
Chris T