[Javascript] Re: newbie question
Cutter (javascript list)
javascript at theblades-family.com
Wed Nov 6 16:04:00 CST 2002
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
More information about the Javascript
mailing list