[Javascript] newbie question

Senior, Henry (TWIi London) HSenior at twii.net
Thu Nov 7 12:48:10 CST 2002


javascript is case sensitive, and 'if' is all lowercase. This will stop your
verify function from working.

function verify() {
If (document.openp2.total.value != 'STAFF1FT');
alert ("Check your addition");
}

you don't put a semicolon after if conditions
only after commands.
this is wrong:
If (document.openp2.total.value != 'STAFF1FT');
should be:

if (document.openp2.total.value != 'STAFF1FT')

also do you want the value of document.openp2.total to be a string
'STAFF1FT'
do you mean:

if(document.openp2.total.value != document.openp2.STAFF1FT.value)

ie the value of form element STAFF1FT






-----Original Message-----
From: javascript-request at LaTech.edu
[mailto:javascript-request at LaTech.edu]
Sent: 07 November 2002 18:01
To: javascript at LaTech.edu
Subject: Javascript digest, Vol 1 #801 - 9 msgs


Send Javascript mailing list submissions to
	javascript at LaTech.edu

To subscribe or unsubscribe via the World Wide Web, visit
	https://lists.LaTech.edu/mailman/listinfo/javascript
or, via email, send a message with subject or body 'help' to
	javascript-request at LaTech.edu

You can reach the person managing the list at
	javascript-admin at LaTech.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Javascript digest..."


Today's Topics:

   1. newbie question (Cheryl Kirkpatrick)
   2. JavaScript List Unsubscirbe, Subscribe & Posting Info. (David
Merchant)
   3. Re: newbie question (Esther_Strom at hmco.com)
   4. Re: newbie question (Cutter (javascript list))
   5. Re: newbie question (wallylaw at yahoo.com)
   6. Re: newbie question (Michael Ledig)
   7. Re: newbie question (Cutter (javascript list))
   8. JavaScript List Unsubscirbe, Subscribe & Posting
       Info. (David Merchant)

--__--__--

Message: 1
Date: Wed, 06 Nov 2002 15:53:58 -0500
From: Cheryl Kirkpatrick <cheryl at leo.scsl.state.sc.us>
Organization: South Carolina State Library
To: javascript list <javascript at LaTech.edu>
Subject: [Javascript] newbie question
Reply-To: javascript at LaTech.edu

I am trying to use Javascript to verify the addition in an online form.
My boss wants the user to supply the sum of several numbers and than
have the form verify the sum. I am trying to get a simple version
working before I plug it in my form. The addition works fine but I can't
get the If then statement to work.

Can you tell me what I am doing wrong?


function add() {
A = document.openp2.ALA1FT.value
B = document.openp2.MLS1FT.value
A = Number(A)
B = Number(B)
C = (A + B)
document.openp2.total.value = C

}
function verify() {
If (document.openp2.total.value != 'STAFF1FT');
alert ("Check your addition");
}

</SCRIPT>

</head>

<body>

<FORM name="openp2">
l<input type="hidden" name="total" size="3" maxlength="3">

<p>full time librarians: <input type="text" name="ALA1FT" size="3"
maxlength="3" value=""></p>

<p>part time librarians: <input type="text" name="MLS1FT" size="3"
maxlength="3" value=""></p>


Total staff: <input type="text" name="STAFF1FT" size="3" maxlength="3">


<p>

<input type=button name= b1 value="Submit data" onClick = add();
verify()>

</p>


</form>

Thank you in advance!
--
Cheryl Kirkpatrick
Web Administrator/
Information Technology Librarian
South Carolina State Library
http://www.state.sc.us/scsl/
Telephone: 803.734.5831



--__--__--

Message: 2
Date: Wed, 06 Nov 2002 14:46:19 -0600
To: javascript at LaTech.edu
From: David Merchant <merchant at LATECH.EDU>
Subject: [Javascript] JavaScript List Unsubscirbe, Subscribe & Posting Info.
Reply-To: javascript at LaTech.edu

--=====================_10737936==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

There are two sets of instructions, first for those who joined the list 
directly and second for those who joined the list via egroups (at present I 
cannot manually unsubscribe anyone who joined via Yahoo Groups or eGroups).

1. If you wish to subscribe or unsubscribe, visit 
https://lists.LaTech.edu/mailman/listinfo/javascript or send a message with 
the word `help' in it to the request address, 
javascript-request at LaTech.edu, for further instructions.

To post to the list, send your posts to javascript at latech.edu

2. For those who subscribed to the Javascript list via Yahoo Groups 
(formally eGroups), here is how to unsubscribe:

To unsubscribe via email:

 From your email program, send a blank message to: 
javascript-unsubscribe at yahoogroups.com

To unsubscribe via the Web:

* Sign in to Yahoo! Groups and go to the My Groups page.
* Click on the Edit Message Settings link at the top of the page.
* Look for the group you wish to unsubscribe from, and select Unsubscribe 
from the pull-down list on the right.
* Click Update to save your changes. The group will no longer be listed on 
the My Groups page, and you will no longer receive messages.

Note: If you own a group, you must first give up your ownership in the
Members section of your group before you can unsubscribe on the My Groups
page.

I CANNOT manually unsubscribe you if you subscribed to the list via eGroups 
or Yahoo Groups. I have complained _repeatedly_ about this to the folks at 
Yahoo Groups, but to no avail. I can only manually unsubscribe those who 
joined via https://lists.LaTech.edu/mailman/listinfo/javascript.

TTFN,
David

Director of Integrated Technology
CATALyST
Louisiana Tech University
Carson Taylor Hall, Rm. 120
PO Box 3179
Ruston, LA 71272
Tel: (318) 257-4772
Fax: (318) 257-3852
projectlife.latech.edu
c3.latech.edu
catalyst.latech.edu
--=====================_10737936==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
There are two sets of instructions, first for those who joined the list
directly and second for those who joined the list via egroups (at present
I cannot manually unsubscribe anyone who joined via Yahoo Groups or
eGroups).<br><br>
1. If you wish to subscribe or unsubscribe, visit
<a href="https://lists.latech.edu/mailman/listinfo/javascript"
eudora="autourl">https://lists.LaTech.edu/mailman/listinfo/javascript</a>
or send a message with the word `help' in it to the request address,
javascript-request at LaTech.edu, for further instructions.<br><br>
To post to the list, send your posts to javascript at latech.edu<br><br>
2. For those who subscribed to the Javascript list via Yahoo Groups
(formally eGroups), here is how to unsubscribe:<br><br>
To unsubscribe via email:<br><br>
 From your email program, send a blank message to:
javascript-unsubscribe at yahoogroups.com<br><br>
To unsubscribe via the Web:<br><br>
* Sign in to Yahoo! Groups and go to the My Groups page.<br>
* Click on the Edit Message Settings link at the top of the page.<br>
* Look for the group you wish to unsubscribe from, and select Unsubscribe
from the pull-down list on the right.<br>
* Click Update to save your changes. The group will no longer be listed on
the My Groups page, and you will no longer receive messages.<br><br>
Note: If you own a group, you must first give up your ownership in the<br>
Members section of your group before you can unsubscribe on the My
Groups<br>
page.<br><br>
I CANNOT manually unsubscribe you if you subscribed to the list via eGroups
or Yahoo Groups. I have complained _repeatedly_ about this to the folks at
Yahoo Groups, but to no avail. I can only manually unsubscribe those who
joined via <a href="https://lists.latech.edu/mailman/listinfo/javascript"
eudora="autourl">https://lists.LaTech.edu/mailman/listinfo/javascript</a>.<b
r><br>
TTFN,<br>
David<br>
<x-sigsep><p></x-sigsep>
Director of Integrated Technology <br>
CATALyST<br>
Louisiana Tech University <br>
Carson Taylor Hall, Rm. 120 <br>
PO Box 3179 <br>
Ruston, LA 71272 <br>
Tel: (318) 257-4772 <br>
Fax: (318) 257-3852<br>
<font color="#0000FF"><u>projectlife.latech.edu<br>
c3.latech.edu<br>
catalyst.latech.edu</font></u></html>

--=====================_10737936==_.ALT--


--__--__--

Message: 3
Subject: Re: [Javascript] newbie question
To: javascript at LaTech.edu
From: Esther_Strom at hmco.com
Date: Wed, 6 Nov 2002 14:48:15 -0600
Reply-To: javascript at LaTech.edu


I'm guessing that with this line:

If (document.openp2.total.value != 'STAFF1FT');

you are wanting to make sure the value of the total field is not equal to
the value of the STAFF1FT field. To do this, you need to reference that
field's value, not its name:

If (document.openp2.total.value != document.openp2.STAFF1FT.value);
|------------------------------|
| E S T H E R  S T R O M, CLPP |
| Notes Application Development|
| McDougal Littell             |
| 909 Davis Street             |
| Evanston, IL 60201 USA       |
| w: 847.424.3209              |
| e: esther_strom at hmco.com     |
|------------------------------|





 

                      Cheryl Kirkpatrick

                      <cheryl at leo.scsl.s         To:      javascript list
<javascript at LaTech.edu>                                        
                      tate.sc.us>                cc:

                      Sent by:                   Subject: [Javascript]
newbie question                                                   
                      javascript-admin at L

                      aTech.edu

 

 

                      11/06/2002 02:53

                      PM

                      Please respond to

                      javascript

 

 





I am trying to use Javascript to verify the addition in an online form.
My boss wants the user to supply the sum of several numbers and than
have the form verify the sum. I am trying to get a simple version
working before I plug it in my form. The addition works fine but I can't
get the If then statement to work.

Can you tell me what I am doing wrong?


function add() {
A = document.openp2.ALA1FT.value
B = document.openp2.MLS1FT.value
A = Number(A)
B = Number(B)
C = (A + B)
document.openp2.total.value = C

}
function verify() {
If (document.openp2.total.value != 'STAFF1FT');
alert ("Check your addition");
}

</SCRIPT>

</head>

<body>

<FORM name="openp2">
l<input type="hidden" name="total" size="3" maxlength="3">

<p>full time librarians: <input type="text" name="ALA1FT" size="3"
maxlength="3" value=""></p>

<p>part time librarians: <input type="text" name="MLS1FT" size="3"
maxlength="3" value=""></p>


Total staff: <input type="text" name="STAFF1FT" size="3" maxlength="3">


<p>

<input type=button name= b1 value="Submit data" onClick = add();
verify()>

</p>


</form>

Thank you in advance!
--
Cheryl Kirkpatrick
Web Administrator/
Information Technology Librarian
South Carolina State Library
http://www.state.sc.us/scsl/
Telephone: 803.734.5831


_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript






--__--__--

Message: 4
From: "Cutter (javascript list)" <javascript at theblades-family.com>
To: javascript at LaTech.edu
Date: Wed, 06 Nov 2002 17:04:00 -0500
Subject: [Javascript] Re: newbie question
Reply-To: javascript at LaTech.edu

Cheryl, 

What type of field is total? If it is a text field then it should work, but 
if it is a select then you must reference the value very differently. 

Cutter
Falcon Knives 

Cheryl Kirkpatrick writes: 

> I am trying to use Javascript to verify the addition in an online form.
> My boss wants the user to supply the sum of several numbers and than
> have the form verify the sum. I am trying to get a simple version
> working before I plug it in my form. The addition works fine but I can't
> get the If then statement to work. 
> 
> Can you tell me what I am doing wrong? 
> 
> 
> function add() {
> A = document.openp2.ALA1FT.value
> B = document.openp2.MLS1FT.value
> A = Number(A)
> B = Number(B)
> C = (A + B)
> document.openp2.total.value = C 
> 
> }
> function verify() {
> If (document.openp2.total.value != 'STAFF1FT');
> alert ("Check your addition");
> } 
> 
> </SCRIPT> 
> 
> </head> 
> 
> <body> 
> 
> <FORM name="openp2">
> l<input type="hidden" name="total" size="3" maxlength="3"> 
> 
> <p>full time librarians: <input type="text" name="ALA1FT" size="3"
> maxlength="3" value=""></p> 
> 
> <p>part time librarians: <input type="text" name="MLS1FT" size="3"
> maxlength="3" value=""></p> 
> 
> 
> Total staff: <input type="text" name="STAFF1FT" size="3" maxlength="3"> 
> 
> 
> <p> 
> 
> <input type=button name= b1 value="Submit data" onClick = add();
> verify()> 
> 
> </p> 
> 
> 
> </form> 
> 
> Thank you in advance!
> --
> Cheryl Kirkpatrick
> Web Administrator/
> Information Technology Librarian
> South Carolina State Library
> http://www.state.sc.us/scsl/
> Telephone: 803.734.5831 
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
 

--__--__--

Message: 5
Date: Wed, 6 Nov 2002 20:36:17 -0800 (PST)
From: <wallylaw at yahoo.com>
Subject: Re: [Javascript] newbie question
To: javascript at LaTech.edu
Reply-To: javascript at LaTech.edu

Cheryl,
You've probably already gotten some solutions (I can't check my e-mail
via my regular account), but in case you haven't heard back on this,
this should work for you:
< script language="JavaScript" > < !--
function add() {
	A = openp2.ALA1FT.value;
	B = openp2.MLS1FT.value;
	openp2.total.value = (A + B);
	verify();
}

function verify() {
	if (openp2.total.value != openp2.STAFF1FT.value) {
		alert ("Check your addition.");
	}
}
/ /-- > < /script>

The last line in your form code should omit the call to "verify()",
since that is taken care of by the call to "add()":
< input type=button name= b1 value="Submit data" onClick = add(); >

HTH,
Tommy Simmons
Employment Law Advisory Network
www.employmentlawadvisors.com

--- Cheryl Kirkpatrick <cheryl at leo.scsl.state.sc.us> wrote:
> I am trying to use Javascript to verify the addition in an online
> form.
> My boss wants the user to supply the sum of several numbers and than
> have the form verify the sum. I am trying to get a simple version
> working before I plug it in my form. The addition works fine but I
> can't
> get the If then statement to work.
> 
> Can you tell me what I am doing wrong?
> 
> 
> function add() {
> A = document.openp2.ALA1FT.value
> B = document.openp2.MLS1FT.value
> A = Number(A)
> B = Number(B)
> C = (A + B)
> document.openp2.total.value = C
> 
> }
> function verify() {
> If (document.openp2.total.value != 'STAFF1FT');
> alert ("Check your addition");
> }
> 
> </SCRIPT>
> 
> </head>
> 
> <body>
> 
> <FORM name="openp2">
> l<input type="hidden" name="total" size="3" maxlength="3">
> 
> <p>full time librarians: <input type="text" name="ALA1FT" size="3"
> maxlength="3" value=""></p>
> 
> <p>part time librarians: <input type="text" name="MLS1FT" size="3"
> maxlength="3" value=""></p>
> 
> 
> Total staff: <input type="text" name="STAFF1FT" size="3"
> maxlength="3">
> 
> 
> <p>
> 
> <input type=button name= b1 value="Submit data" onClick = add();
> verify()>
> 
> </p>
> 
> 
> </form>
> 
> Thank you in advance!
> --
> Cheryl Kirkpatrick
> Web Administrator/
> Information Technology Librarian
> South Carolina State Library
> http://www.state.sc.us/scsl/
> Telephone: 803.734.5831

__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

--__--__--

Message: 6
Date: Thu, 07 Nov 2002 10:36:54 +0100
From: Michael Ledig <hobbes_tiger at gmx.de>
To: javascript at LaTech.edu
Subject: Re: [Javascript] newbie question
Reply-To: javascript at LaTech.edu

Hello Cheryl,

Cheryl Kirkpatrick schrieb:
  >
...

  > }
  > function verify() {
  > If (document.openp2.total.value != 'STAFF1FT');
  > alert ("Check your addition");
  > }

The problem with your if-statement is the ";".
If you place it at the end - after the condition - JavaScript finishes
the if-statement and the alert-statement is always(!) executed.

So you should write it this way:

if (document.openp2.total.value != 'STAFF1FT')
     alert ("Check your addition");

You should also take a look at the other hints - they can also help you ;-))

HTH and greetings from Germany
Mike.

-- 
Training und Projekte
http://www.gidel.de



--__--__--

Message: 7
From: "Cutter (javascript list)" <javascript at theblades-family.com>
To: javascript at LaTech.edu
Date: Thu, 07 Nov 2002 08:47:40 -0500
Subject: [Javascript] Re: newbie question
Reply-To: javascript at LaTech.edu

Good catch Mike. I never even saw the semicolon at the end of the condition 
statement... 

Cutter
Falcon Knives 

Michael Ledig writes: 

> Hello Cheryl, 
> 
> Cheryl Kirkpatrick schrieb:
>  >
> ... 
> 
>  > }
>  > function verify() {
>  > If (document.openp2.total.value != 'STAFF1FT');
>  > alert ("Check your addition");
>  > } 
> 
> The problem with your if-statement is the ";".
> If you place it at the end - after the condition - JavaScript finishes
> the if-statement and the alert-statement is always(!) executed. 
> 
> So you should write it this way: 
> 
> if (document.openp2.total.value != 'STAFF1FT')
>     alert ("Check your addition"); 
> 
> You should also take a look at the other hints - they can also help you 
> ;-)) 
> 
> HTH and greetings from Germany
> Mike. 
> 
> -- 
> Training und Projekte
> http://www.gidel.de 
> 
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
 

--__--__--

Message: 8
Date: Thu, 07 Nov 2002 11:53:29 -0600
To: javascript at LaTech.edu
From: David Merchant <merchant at LATECH.EDU>
Subject: [Javascript] JavaScript List Unsubscirbe, Subscribe & Posting
  Info.
Reply-To: javascript at LaTech.edu

--=====================_10368167==_.ALT
Content-Type: text/plain; charset="us-ascii"; format=flowed

There are two sets of instructions, first for those who joined the list 
directly and second for those who joined the list via egroups (at present I 
cannot manually unsubscribe anyone who joined via Yahoo Groups or eGroups).

1. If you wish to subscribe or unsubscribe, visit 
https://lists.LaTech.edu/mailman/listinfo/javascript or send a message with 
the word `help' in it to the request address, 
javascript-request at LaTech.edu, for further instructions.

To post to the list, send your posts to javascript at latech.edu

2. For those who subscribed to the Javascript list via Yahoo Groups 
(formally eGroups), here is how to unsubscribe:

To unsubscribe via email:

 From your email program, send a blank message to: 
javascript-unsubscribe at yahoogroups.com

To unsubscribe via the Web:

* Sign in to Yahoo! Groups and go to the My Groups page.
* Click on the Edit Message Settings link at the top of the page.
* Look for the group you wish to unsubscribe from, and select Unsubscribe 
from the pull-down list on the right.
* Click Update to save your changes. The group will no longer be listed on 
the My Groups page, and you will no longer receive messages.

Note: If you own a group, you must first give up your ownership in the
Members section of your group before you can unsubscribe on the My Groups
page.

*** I CANNOT manually unsubscribe you if you subscribed to the list via 
eGroups or Yahoo Groups. ***
I have complained _repeatedly_ about this to the folks at Yahoo Groups, but 
to no avail. I can only manually unsubscribe those who joined via 
https://lists.LaTech.edu/mailman/listinfo/javascript.

TTFN,
David

Director of Integrated Technology
CATALyST
Louisiana Tech University
Carson Taylor Hall, Rm. 120
PO Box 3179
Ruston, LA 71272
Tel: (318) 257-4772
Fax: (318) 257-3852
projectlife.latech.edu
c3.latech.edu
catalyst.latech.edu
--=====================_10368167==_.ALT
Content-Type: text/html; charset="us-ascii"

<html>
There are two sets of instructions, first for those who joined the list
directly and second for those who joined the list via egroups (at present
I cannot manually unsubscribe anyone who joined via Yahoo Groups or
eGroups).<br><br>
1. If you wish to subscribe or unsubscribe, visit
<a href="https://lists.latech.edu/mailman/listinfo/javascript"
eudora="autourl">https://lists.LaTech.edu/mailman/listinfo/javascript</a>
or send a message with the word `help' in it to the request address,
javascript-request at LaTech.edu, for further instructions.<br><br>
To post to the list, send your posts to javascript at latech.edu<br><br>
2. For those who subscribed to the Javascript list via Yahoo Groups
(formally eGroups), here is how to unsubscribe:<br><br>
To unsubscribe via email:<br><br>
 From your email program, send a blank message to:
javascript-unsubscribe at yahoogroups.com<br><br>
To unsubscribe via the Web:<br><br>
* Sign in to Yahoo! Groups and go to the My Groups page.<br>
* Click on the Edit Message Settings link at the top of the page.<br>
* Look for the group you wish to unsubscribe from, and select Unsubscribe
from the pull-down list on the right.<br>
* Click Update to save your changes. The group will no longer be listed on
the My Groups page, and you will no longer receive messages.<br><br>
Note: If you own a group, you must first give up your ownership in the<br>
Members section of your group before you can unsubscribe on the My
Groups<br>
page.<br><br>
*** I CANNOT manually unsubscribe you if you subscribed to the list via
eGroups or Yahoo Groups. ***<br>
I have complained _repeatedly_ about this to the folks at Yahoo Groups, but
to no avail. I can only manually unsubscribe those who joined via <a
href="https://lists.latech.edu/mailman/listinfo/javascript"
eudora="autourl">https://lists.LaTech.edu/mailman/listinfo/javascript</a>.<b
r><br>
TTFN,<br>
David<br>
<x-sigsep><p></x-sigsep>
Director of Integrated Technology <br>
CATALyST<br>
Louisiana Tech University <br>
Carson Taylor Hall, Rm. 120 <br>
PO Box 3179 <br>
Ruston, LA 71272 <br>
Tel: (318) 257-4772 <br>
Fax: (318) 257-3852<br>
<font color="#0000FF"><u>projectlife.latech.edu<br>
c3.latech.edu<br>
catalyst.latech.edu</font></u></html>

--=====================_10368167==_.ALT--



--__--__--

_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript


End of Javascript Digest


DISCLAIMER - The preceding e-mail message (including any attachments)
contains information that may be confidential, may be protected by the
attorney-client or other applicable privileges, or may constitute non-public
information.  It is intended to be conveyed only to the designated
recipient(s) named above.  If you are not an intended recipient of this
message, or have otherwise received it in error, please notify the sender by
replying to this message and then delete all copies of it from your computer
system.  Any use, dissemination, distribution, or reproduction of this
message by unintended recipients is not authorized and may be unlawful. The
contents of this communication do not necessarily represent the views of
this company.



More information about the Javascript mailing list