Wrox Programmer Forums
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2004, 05:58 PM
Registered User
 
Join Date: Nov 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default division by zero

can anyone help fix this statement?

var a = this.getField("PREM&LOSS.0.2").value

var b = this.getField("PREM&LOSS.0.1").value

var f = this.getField("PREM&LOSS.0.33333")
f.value = b/a

I'm getting the error "the value entered does not match the format of the field" I was informed I need an if state "As an example, let's assume that we have a simple division c = a/b. In
order to prevent illegal results, we would have to prevent a division
by zero. This means that b must not be zero, whereas a can have any
value except zero. In pseudo code, we would have the following script:

if (b.value == "" || b.value == "" && a.value == "") {
//suppress this calculation and all others depending on c
} else {
// do the calculations
}
But i do not understand how to fix this.
 
Old November 9th, 2004, 08:03 AM
Friend of Wrox
 
Join Date: Jul 2004
Posts: 204
Thanks: 0
Thanked 0 Times in 0 Posts
Default

What dont you understand exactly, you seem to know how the if statement works already, so what exactly is the problem?

I am not sure why you are using the test you are in the if statement, I would have thought that if either 'a' or 'b' was 0 you would want it to fail, unless you want to end up with something like 0/99, where a = 0 and b = 99.

What is the difference between:

"This means that b must not be zero, whereas a can have any
value except zero"

What this says to me is that neither value should be 0.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Division by zero Corey BOOK: Beginning Access 2003 VBA 2 April 13th, 2007 02:56 PM
Division by zero error Corey Access 4 October 20th, 2005 12:51 PM
IIf Statement "division by zero" error Corey BOOK: Beginning Access 2003 VBA 5 September 30th, 2005 05:48 AM
Performing Division in XSLT... Please help.. kiril XSLT 3 May 17th, 2004 05:27 AM
Division by zero error ss2003 Beginning PHP 5 January 1st, 2004 11:51 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.