I'm hoping one of you javascript guru's can help me because i'm new at javascript!!!
I need to return the score from my function and have it emailed with the test results. How do i do it?
here is the code: (i know it's mickey mouse but it took me a while to get it to work)

<title>Introduction to Disease Management Test</title>

<script language="javascript">

function tester() 

var a1 = 0; 
var a2 = 0; 
var a3 = 0; 
var a4 = 0;

for (i=0;i<document.test1Form.q1.length;i++){
if (document.test1Form.q1[i].checked){

for (i=0;i<document.test1Form.q2.length;i++){
if (document.test1Form.q2[i].checked){

for (i=0;i<document.test1Form.q3.length;i++){
if (document.test1Form.q3[i].checked){

for (i=0;i<document.test1Form.q4.length;i++){
if (document.test1Form.q4[i].checked){


if(q1value=="d")    {a1 = 1;} 
if(q2value=="d")    {a2 = 1;} 
if(q3value=="b")    {a3 = 1;} 
if(q4value=="e")    {a4 = 1;} 

total = a1 + a2 + a3 + a4; 

grade = 25*total; 

if (total < 100) { alert("Your score is "+ grade +"%."); }

return grade;




<FORM name="test1Form" action="xxxxxxxxxxxxxx" method="post" target="_top" onSubmit="tester()">
<INPUT type="hidden" value="xxxx@xxx.xxx" name="recipient">
<INPUT type="hidden" value="Intro to DM Test" name="subject">
<INPUT type="hidden" value="http:/xxxxxxxxxxx/" name="redirect">
<INPUT type="hidden" name="env_report" VALUE="REMOTE_HOST,HTTP_USER_AGENT">
<INPUT type="hidden" name="print_blank_fields" VALUE="1">
<INPUT type="hidden" name="required" value="name,date,department,license,q1,q2,q3,q4">

<!--<form method=post enctype="text/plain" action="mailto:xxxxx@xxxx.xxx">-->


Name:<input type="text" name="name" size=50><br>
Date:<input type="text" name="date"><br>
Department:<input type="text" name="department" size=54><br>
License # (Required for RNs, LVNs & OTs): <input type="text" name="license"></p>

<p><b>DIRECTION: Choose the BEST answer.</b></p>
<br><b>1. Which of the following are key aspects of a home care disease management program?</b>
<br><input type="radio" name="q1" value="a">a)	It emphasizes prevention of exacerbations and complications of chronic diseases.
<br><input type="radio" name="q1" value="b">b)	It uses strategies to empower the patient to understand and manage their own chronic diseases.
<br><input type="radio" name="q1" value="c">c)	It involves the coordination of healthcare interventions to manage a patient’s chronic diseases.
<br><input type="radio" name="q1" value="d">d)	All of the above
<br><b>2. Which of the following conditions would not be appropriate for a home care disease management program?</b>
<br><input type="radio" name="q2" value="a">a)	Congestive Heart Failure
<br><input type="radio" name="q2" value="b">b)	Diabetes
<br><input type="radio" name="q2" value="c">c)	Hip replacement
<br><input type="radio" name="q2" value="d">d)	Home IV antibiotics for pneumonia
<br><input type="radio" name="q2" value="e">e)	Chronic Obstructive Lung Disease
<br><b>3. Key outcomes expected from a home care disease management program include all the following except?</b>
<br><input type="radio" name="q3" value="a">a)	Reduced emergency room visits
<br><input type="radio" name="q3" value="b">b)	Less reliance on physicians
<br><input type="radio" name="q3" value="c">c)  Avoidance of unplanned hospitalizations
<br><input type="radio" name="q3" value="d">d)	Improved clinical outcome measures
<br><input type="radio" name="q3" value="e">e)	Improved patient satisfaction

<br><b>4. Patient self-management is a central component of a home care disease management program.  Home care agencies have clear advantages in promoting and assessing patient self-management education because of all the following except.</b>

<br><input type="radio" name="q4" value="a">a)	The patient is more comfortable and less anxious at home, creating a better environment for education
<br><input type="radio" name="q4" value="b">b)	Trust and confidence develops in the home care clinician over time because of repeated visits
<br><input type="radio" name="q4" value="c">c)	Home care staff are in a position of being able to observe the patient’s understanding of specific intervention activities
<br><input type="radio" name="q4" value="d">d)	Home care staff get an insight into the patient’s issues that might lead to non-adherence to specific treatment guidelines.
<br><input type="radio" name="q4" value="e">e)	Patient’s are more captive in the homes and therefore feel obligated to follow the home care staff’s recommendations.

<br> <input type="submit" value="Submit Test">

8 Years
Discussion Span
Last Post by DangerDev

if you want to have the script email the results, it would probably be easier and safer to use a server side script like PHP . i could be wrong but, i dont even think javascript will send emails.

   function sendMail()
		var mailId="you@yourmail.com";
		var subject="subject you want";
		var cc="cc@other.com";
<a href="javascript:sendMail()">mail someone</a>

above code will open the default email client of the user (e.g. Outlook Express, etc.).

as hunkychop^ said, it will be good idea to use server side script to send the mail.
send data to the server by some means (either by form submit or by ajax) and their you form mail body and send mail.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.