[Javascript] newbie question

Esther_Strom at hmco.com Esther_Strom at hmco.com
Wed Nov 6 14:48:15 CST 2002


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








More information about the Javascript mailing list