Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Large mathematical equation help

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 03-03-2005, 09:29 PM PM User | #1 jglover New Coder   Join Date: Oct 2004 Posts: 13 Thanks: 0 Thanked 0 Times in 0 Posts Large mathematical equation help Hello, I have a script I need to run a large equation for. I'm guessing my style of the math is wrong. Here is what I have, any help would be so greatly appreciated. Piece of code with trouble: hwfcfp=(form1.lean6.value*((100-form1.fat6.value)/100)+form1.lean5.value*((100-form1.fat5.value)/100)+form1.lean4.value*((100-form1.fat4.value)/100)+form1.lean3.value*((100-form1.fat3.value)/100)+form1.lean2.value*((100-form1.fat2.value)/100)+form1.lean1.value*((100-form1.fat1.value)/100)); form1.hwfcfp.value=hwfcfp.toFixed(2) and if you need it, here is the rest of the page: Pre-Rigor Fat Correction Worksheet

Pre-Rigor Fat Correction Worksheet

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage
Desired Lean Percentage
Desired Salt Percentage
Desired Water Percentage
Fat Correction Fat Percentage (FCFP)
Total WeightPercent Lean
Total Lean Weight
Salt to add woth fat (lbs)
 03-03-2005, 09:35 PM PM User | #2 jglover New Coder   Join Date: Oct 2004 Posts: 13 Thanks: 0 Thanked 0 Times in 0 Posts I think I may have figured it out, if you see something wrong please let me know.
 03-04-2005, 12:19 AM PM User | #3 jglover New Coder   Join Date: Oct 2004 Posts: 13 Thanks: 0 Thanked 0 Times in 0 Posts Ok Everything seems to be working except one equation and I've been working on it for 3 hours. This project is pretty much just an excel spreadsheet carried over. I used the same formulas from the excel spreadsheet and they all work but this one. PLEASE HELP! tpercent=(form1.hwfcfp.value+form1.htlweight.value)/(form1.tfcfp.value+form1.tlweight.value); form1.tpercent.value=tpercent.toFixed(2); All of code: Pre-Rigor Fat Correction Worksheet

Pre-Rigor Fat Correction Worksheet

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage

Lean Weight (lbs):
Fat Percentage
Desired Lean Percentage
Desired Salt Percentage
Desired Water Percentage
Fat Correction Fat Percentage (FCFP)
Total WeightPercent Lean
Total Lean Weight
Salt to add with fat (lbs)
 03-04-2005, 12:23 AM PM User | #4 jkd Senior Coder     Join Date: May 2002 Location: metro DC Posts: 3,163 Thanks: 1 Thanked 18 Times in 18 Posts someFormElement.value is always a String, not a Number. Use parseInt(someFormElement.value) or parseFloat to make it a Number. __________________ jasonkarldavis.com
 03-04-2005, 12:28 AM PM User | #5 jglover New Coder   Join Date: Oct 2004 Posts: 13 Thanks: 0 Thanked 0 Times in 0 Posts I did this: tpercent=parseInt(form1.hwfcfp.value+form1.htlweight.value)/parseInt(form1.tfcfp.value+form1.tlweight.value); got #'s now just not right ones New to this, never used parsInt before. Any Ideas?
 03-04-2005, 05:49 AM PM User | #6 glenngv Supreme Master coder!     Join Date: Jun 2002 Location: Los Angeles, CA Original Location: Philippines Posts: 10,676 Thanks: 0 Thanked 190 Times in 187 Posts You need to parseInt each value separately tpercent = (parseInt(form1.hwfcfp.value) + parseInt(form1.htlweight.value))/(parseInt(form1.tfcfp.value) + parseInt(form1.tlweight.value)); If you expect decimal numbers, use parseFloat instead of parseInt. __________________ Glenn _____________________________________________ Tower of Hanoi Android app (Ad-FREE!) Tower of Hanoi Android app (FREE!) Tower of Hanoi Leaderboard vBulletin 5 Floating Bar extension vBulletin 5 Slideshow extension vBulletin 5 Quote Selected Text extension vBulletin 5 Profile Preview Tooltip extension
 03-04-2005, 04:01 PM PM User | #7 jglover New Coder   Join Date: Oct 2004 Posts: 13 Thanks: 0 Thanked 0 Times in 0 Posts Thank you very much, works like a charm!

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 11:23 AM.