[Javascript] newbie question

Cheryl Kirkpatrick cheryl at leo.scsl.state.sc.us
Wed Nov 6 14:53:58 CST 2002


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





More information about the Javascript mailing list