I'm a rank beginner with Javascript. The offending page is at http://www.longerstrongerliving.com/stresscalc.htm.

On loading the page, there is an "Expected J" at line 13, character 25.

After putting a numeric value in each of the text boxes for the 17 questions, there is an "Object Expected" error, line 148, character 1.

Furthermore, the "Total Score" text box stubbornly refuses to display anything, despite the numerous wild guesses I have made about code.

Are there any gurus willing to take a look and offer some welcome advice?


Hi there,

Well there is nothing big problem with code :)

Just Missing ";" semicolons and field names should not be the numeric

Here is the working code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Personal Stress Calculator - Longer, Stronger, Living!</title>
<link rel='stylesheet' type='text/css' href='stylem.css' />
<script language="JavaScript" type="text/javascript">
	function calculate() {
			var A = eval(document.frmOne.A1.value);
			B = eval(document.frmOne.A2.value);
			C = eval(document.frmOne.A3.value);
			D = eval(document.frmOne.A4.value);
			E = eval(document.frmOne.A5.value);
			F = eval(document.frmOne.A6.value);
			G = eval(document.frmOne.A7.value);
			H = eval(document.frmOne.A8.value);
			I = eval(document.frmOne.A9.value);
			J = eval(document.frmOne.A10.value);
			K = eval(document.frmOne.A11.value);
			L = eval(document.frmOne.A12.value);
			M = eval(document.frmOne.A13.value);
			N = eval(document.frmOne.A14.value);
			O = eval(document.frmOne.A15.value);
			P = eval(document.frmOne.A16.value);
			Q = eval(document.frmOne.A17.value);
				R = (A + B + C + D + E + F + G + H + I + J + K + L + M + N + O + P + Q);
			document.frmOne.A18.value = R;
<p>Home Page of<br />
  <a href="http://www.longerstrongerliving.com">&quot;Longer, Stronger, Living!&quot;</a></p>
<h1><b>Personal Stress Calculator</b></h1>
<form id="form1" name="frmOne" method="post" action=""><table border="0">
    <td width="3%">Q1</td>
    <td width="88%">Adapt quickly. Good at bouncing back from difficulties.</td>
    <td width="9%"><input type="text" name="A1" size="5" value="" /></td>
    <td>Optimistic, see difficulties as temporary, expect to overcome them and have things to turn out well.</td>
    <td><input type="text" name="A2" size="5" value="" /></td>
    <td>In a crisis I calm myself and focus on taking useful actions.</td>
    <td><input type="text" name="A3" size="5" value="" /></td>
    <td>Good at solving problems logically.</td>
    <td><input type="text" name="A4" size="5" value="" /></td>
    <td>Can think up creative solutions to challenges. Trust intuition.</td>
    <td><input type="text" name="A5" size="5" value="" /></td>
    <td>Playful, find the humor, laugh at self, chuckle.</td>
    <td><input type="text" name="A6" size="5" value="" /></td>
    <td>Curious, ask questions, want to know how things work, experiment. </td>
    <td><input type="text" name="A7" size="5" value="" /></td>
    <td>Constantly learn from experience and from the experiences of others.</td>
    <td><input type="text" name="A8" size="5" value="" /></td>
    <td>Very flexible. Feel comfortable with inner complexity (trusting and cautious, unselfish and selfish, optimistic and pessimistic, etc.)</td>
    <td><input type="text" name="A9" size="5" value="" /></td>
    <td>Anticipate problems to avoid them and expect the unexpected.</td>
    <td><input type="text" name="A10" size="5" value="" /></td>
    <td>Able to tolerate ambiguity and uncertainty about situations.</td>
    <td><input type="text" name="A11" size="5" value="" /></td>
    <td>Feel self-confident, enjoy healthy self-esteem, and have an attitude of professionalism about work.</td>
    <td><input type="text" name="A12" size="5" value="" /></td>
    <td>Good listener. Good empathy skills. &quot;Read&quot; people well. Can adapt to various personality styles. Non-judgmental (even with difficult people).</td>
    <td><input type="text" name="A13" size="5" value="" /></td>
    <td>Able to recover emotionally from losses and setbacks. Can express feelings to others, let go of anger, overcome discouragement, and ask for help.</td>
    <td><input type="text" name="A14" size="5" value="" /></td>
    <td>Very durable, keep on going during tough times. Independent spirit.</td>
    <td><input type="text" name="A15" size="5" value="" /></td>
    <td>Have been made stronger and better by difficult experiences.</td>
    <td><input type="text" name="A16" size="5" value="" /></td>
    <td>Convert misfortune into good fortune. Discover the unexpected benefit.</td>
    <td><input type="text" name="A17" size="5" value="" /></td>
    <td colspan="3"><div align="center">
        <input type="button" name="b1" value="Add Scores" onclick="calculate();" />
        <input name="reset" type="reset" value="Reset Scores" />
    <td colspan="3"><div align="center"><b>Total &quot;Stress&quot; Score</b>&nbsp;&nbsp;&nbsp;
        <input type="text" name="A18" size="5" value="" />
commented: Fantastic! Really sound advice that worked! +2


I am so GRATEFUL for your quick and effective response! The page is up and running beautifully.

You gave me an opportunity to refine the questionnaire using "Select Options" because the core structure of your code was sound.

If you have the time and inclination take a look at http://www.longerstrongerliving.com/tools/adaptability.htm.

Thanks again!!!!