User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,554 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,609 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 1599 | Replies: 2
Reply
Join Date: Apr 2005
Location: Australia
Posts: 23
Reputation: numerouno is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
numerouno's Avatar
numerouno numerouno is offline Offline
Newbie Poster

Help Javascript - Expected J and Expected Object errors

  #1  
Feb 16th, 2007
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?

Progress Enterprise

http://www.progressenterprise.com
Home of "Write Yourself A Job!" - a "how to" guide to writing your Resume or CV
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Location: india
Posts: 143
Reputation: katarey is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 15
katarey's Avatar
katarey katarey is offline Offline
Junior Poster

Solution Re: Javascript - Expected J and Expected Object errors

  #2  
Feb 16th, 2007
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


[HTML]
<!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">
<head>
<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">
//<![CDATA[
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;
}
//]]>
</script>
</head>
<body>
<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">
<tr>
<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>
</tr>
<tr>
<td>Q2</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>
</tr>
<tr>
<td>Q3</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>
</tr>
<tr>
<td>Q4</td>
<td>Good at solving problems logically.</td>
<td><input type="text" name="A4" size="5" value="" /></td>
</tr>
<tr>
<td>Q5</td>
<td>Can think up creative solutions to challenges. Trust intuition.</td>
<td><input type="text" name="A5" size="5" value="" /></td>
</tr>
<tr>
<td>Q6</td>
<td>Playful, find the humor, laugh at self, chuckle.</td>
<td><input type="text" name="A6" size="5" value="" /></td>
</tr>
<tr>
<td>Q7</td>
<td>Curious, ask questions, want to know how things work, experiment. </td>
<td><input type="text" name="A7" size="5" value="" /></td>
</tr>
<tr>
<td>Q8</td>
<td>Constantly learn from experience and from the experiences of others.</td>
<td><input type="text" name="A8" size="5" value="" /></td>
</tr>
<tr>
<td>Q9</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>
</tr>
<tr>
<td>Q10</td>
<td>Anticipate problems to avoid them and expect the unexpected.</td>
<td><input type="text" name="A10" size="5" value="" /></td>
</tr>
<tr>
<td>Q11</td>
<td>Able to tolerate ambiguity and uncertainty about situations.</td>
<td><input type="text" name="A11" size="5" value="" /></td>
</tr>
<tr>
<td>Q12</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>
</tr>
<tr>
<td>Q13</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>
</tr>
<tr>
<td>Q14</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>
</tr>
<tr>
<td>Q15</td>
<td>Very durable, keep on going during tough times. Independent spirit.</td>
<td><input type="text" name="A15" size="5" value="" /></td>
</tr>
<tr>
<td>Q16</td>
<td>Have been made stronger and better by difficult experiences.</td>
<td><input type="text" name="A16" size="5" value="" /></td>
</tr>
<tr>
<td>Q17</td>
<td>Convert misfortune into good fortune. Discover the unexpected benefit.</td>
<td><input type="text" name="A17" size="5" value="" /></td>
</tr>
<tr>
<td colspan="3"><div align="center">
<input type="button" name="b1" value="Add Scores" onclick="calculate();" />
&nbsp;
<input name="reset" type="reset" value="Reset Scores" />
</div></td>
</tr>
<tr>
<td colspan="3"><div align="center"><b>Total &quot;Stress&quot; Score</b>&nbsp;&nbsp;&nbsp;
<input type="text" name="A18" size="5" value="" />
</div></td>
</tr>
</table></form>
</body>
</html>

[/HTML]
Freelance Web Designer & Developer
Http//www.Katarey.com
Reply With Quote  
Join Date: Apr 2005
Location: Australia
Posts: 23
Reputation: numerouno is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
numerouno's Avatar
numerouno numerouno is offline Offline
Newbie Poster

Re: Javascript - Expected J and Expected Object errors

  #3  
Feb 16th, 2007
Katarey,

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/...aptability.htm.

Thanks again!!!!
Progress Enterprise

http://www.progressenterprise.com
Home of "Write Yourself A Job!" - a "how to" guide to writing your Resume or CV
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb JavaScript / DHTML / AJAX Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum

All times are GMT -4. The time now is 9:29 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC