🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.javascript
Article #67

Formfield validation problems

#67
From: Tor-Arne Bertheussen
Date: Mon, 20 Mar 2000 00:00
61 lines
2660 bytes
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 ;

}

</SCRIPT>
</HEAD>
<BODY>

<p>
<form name="theForm" method="POST" action="">

<select name="q2n" size="1" onChange="Calculate(this.form);">
  <option value="0">0%</option>
  <option value="10">10%</option>
  <option value="20">20%</option>
</select>

<p>Sum: <input type="text" name="sum" size="3" onFocus="this.blur()">
<p><input type="submit" value="Continue" name="Continue"></p>

</form>

</BODY>
</HTML>
Technical Details
Message-ID: <38D64B6B.B5AA65A5@online.no>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb3cb,f5daaefc94e8e839,start
X-Google-Attributes: gidfb3cb,public
X-Google-Thread: 10731d,f5daaefc94e8e839,start
X-Google-Attributes: gid10731d,public
X-Google-Thread: 113fd6,f5daaefc94e8e839,start
X-Google-Attributes: gid113fd6,public
X-Google-Thread: fcc66,f5daaefc94e8e839,start
X-Google-Attributes: gidfcc66,public
From: Tor-Arne Bertheussen <toberthe@online.no>
Subject: Formfield validation problems
Date: 2000/03/20
Message-ID: <38D64B6B.B5AA65A5@online.no>
X-Deja-AN: 599978020
Content-Transfer-Encoding: 7bit
X-Accept-Language: en
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news-abuse@online.no
X-Trace: news1.online.no 953568108 129.240.17.211 (Mon, 20 Mar 2000 17:01:48 MET)
Organization: Telenor Online Public Access
MIME-Version: 1.0
NNTP-Posting-Date: Mon, 20 Mar 2000 17:01:48 MET
Newsgroups: comp.lang.javascript,borland.public.intrabuilder.javascript,de.comp.lang.javascript,it.comp.lang.javascript