🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.javascript
Article #68

Re: Formfield validation problems

#68
From: Lee
Date: Mon, 20 Mar 2000 00:00
56 lines
2446 bytes
Tor-Arne said:
>
>I feel completely lost and hope somebody could help me out on this.
>
>What I'm trying to do is to make the user of a form select some values
>from a number of drop-down lists. The sum of all the values is supposted
>to be added and presented in a textfield that cannot be edited manually.
>Each time the user choose a value from one of the lists the sum is
>recalculated and presented in the text-field.
>
>I have gotten my JavaScript to work fine in Internet Explorer, but not
>in Netscape (ver.4.7). I have attacted my code below.
>
>For some reason the result of eval(document.theForm.q2n.value) is always
>"null". I have also tried to include eval(myForm.q2n.value) to see if
>this gives any other result - with no lucky.
>
>Does anyone know how this problem can be solved?
>
>TIA
>
>Tor-Arne
>
>--------------------------------- Code
>------------------------------------
>
><HTML>
><HEAD>
><TITLE></TITLE>
><SCRIPT LANGUAGE="JavaScript">
>
>function Calculate(myForm)
>{
>   total = 0 ;
>   n = eval(myForm.q2n.value) ;
>
>   document.theForm.sum.value = eval(document.theForm.q2n.value) ;
>
>//   alert(document.theForm.q2n.value + ", " + n + ", " + total) ;
>//   document.theForm.sum.value = total ;
>
>}

See http://www.azphx.com/dhtml/select.html

Here's a function that should work in both browsers as well as yours
does in IE, but neither version correctly handles the case of a user
changing a selection.  For that, you either need to remember each
previous setting or re-total all of your Select objects whenever any
of them is changed.


function Calculate(myForm)
{
myForm.sum.value+=parseInt(myForm.q2n.options[myForm.q2n.selectedIndex].value);
}
Technical Details
Message-ID: <8b5kti$2r1n@drn.newsguy.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38D64B6B.B5AA65A5@online.no>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10731d,f5daaefc94e8e839
X-Google-Attributes: gid10731d,public
X-Google-Thread: fb3cb,f5daaefc94e8e839
X-Google-Attributes: gidfb3cb,public
X-Google-Thread: 113fd6,f5daaefc94e8e839
X-Google-Attributes: gid113fd6,public
X-Google-Thread: fcc66,f5daaefc94e8e839
X-Google-Attributes: gidfcc66,public
From: Lee <boylel@mindspring.com>
Subject: Re: Formfield validation problems
Date: 2000/03/20
Message-ID: <8b5kti$2r1n@drn.newsguy.com>
X-Deja-AN: 600017070
References: <38D64B6B.B5AA65A5@online.no>
Organization: AZ
Newsgroups: comp.lang.javascript,borland.public.intrabuilder.javascript,de.comp.lang.javascript,it.comp.lang.javascript