Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 28th, 2012, 05:58 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Display results of a calculation in an online form

Hello, after searching on the forum i paste this that is getting me nuts, lets start:
I have a online form that have 2 fields that i need to calculate and show it after clicking the calculate button.

The deal is that I have to use a Excel formula that the client need to be used.
Here is the excel formula I need to use (basically is a rule of thre, if G14 is biger than 0 then we divide in 81, but if is 0 theh we work with 66%):

=IF (G14>0,((J21/100)*100%/81%),((J21/100)*100%/66%))

Here is my script:

<script type="text/javascript">
function calculateTextfinal()
{
var op1=document.getElementById('e1');
var op2=document.getElementById('total1');

var result =document.getElementById('total2');

if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;

result.value=0;
result.value=parseInt(result.value);
result.value=parseInt(result.value)+(op1.value * op2.value /0.81);
}
</script>

I guess that the error is in my formula conversion and I need to make an IF the value of op1 (at excel G14) is a cero, any help could be great.

Last edited by ramonolea; May 28th, 2012 at 06:37 PM..
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Display only Online User vai_rajput BOOK: Professional XMPP Programming with JavaScript and jQuery 1 April 18th, 2011 07:45 PM
Calculation using previously entered data in a form wobmat Access VBA 3 July 22nd, 2009 07:17 PM
display results carswelljr ASP.NET 2.0 Basics 1 April 19th, 2007 09:46 AM
How do I display search results... aspiretech9 PHP How-To 1 April 26th, 2005 10:12 AM
How do I display search results... aspiretech9 PHP Databases 1 April 25th, 2005 12:11 PM



All times are GMT -4. The time now is 10:15 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.