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 HELP! Deadline tomorrow! JAVA CALC

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 07-03-2013, 11:54 PM PM User | #1 djarmind New to the CF scene   Join Date: Jul 2013 Posts: 1 Thanks: 0 Thanked 0 Times in 0 Posts HELP! Deadline tomorrow! JAVA CALC Code: ``` valoareTreceri = parseInt(\$('#treceri1').attr('value')); if(!valoareTreceri) { valoare1 = 0; } else { if(tip=='tip1'||tip=='tip3') { valoare1 = f8*1.25*(0.3*(valoareTreceri-1)+1); } }``` I have this java code that calculates "valoare1" as the multiplication of f8 (f8 is a value given earlier in the code) with 1.25 then with 0.3 * "valoareTreceri" wich is a value from 0 to 6 (default 0) taken from html form. ex: if valoareTreceri=4 then valoare1=15*1.25*(0.3*(4-1)+1) = =15 * 1.25 * (1.9)= 35.62 if valoaretreceri=5 then valoare1=15*1.25*(0.3*(5-1)+1)= =15 *1.25* (2.2) = 41.25 So what happens is that valoare1 gets + 30% when valoareTreceri rises. I need that "valoare1" for each "valoareTreceri" (from 1 to 6) to be a fix value. Not to rise procentual. And to define it manualy for each 1 to 6. For example something like this: (the numbers are fictive) if valoareTreceri=1 valoare1=f8+5 if valoareTreceri=2 vlaoare1=f8+19 if valoareTreceri=3 valoare1=f8+20 if valoareTreceri=4 valoare1=f8+38 etc until 6 This valoareTreceri is selected by user in html form and depending to it the price of product changes but not procentual as it is now. If you want to look at the calculation form or the entire code by inspecting element you`ll find it here: www.armedia.ro/test If i didn`t make myself clear i can give further explications. It`s late and I`m tired. PLEASE HELP!!!! I should present this to my boss tomorrow afternoon.
 07-04-2013, 12:16 AM PM User | #2 felgall Master Coder     Join Date: Sep 2005 Location: Sydney, Australia Posts: 6,088 Thanks: 0 Thanked 579 Times in 569 Posts Is this code supposed to be Java or is it supposed to be JavaScript? You are asking about Java but have posted in the JavaScript forum. These are two completely different languages but from what you have posted it is difficult to say which of the two you are trying to use (although the first line of the code does look like poorly written JavaScript). __________________ Stephen Learn Modern JavaScript - http://javascriptexample.net/ Helping others to solve their computer problem at http://www.felgall.com/ Beginners need to advise whether they want to learn "Latin" JavaScript for Netscape 3 or "Italian" JavaScript for modern browsers.
 07-04-2013, 01:23 AM PM User | #3 Old Pedant Supreme Master coder!     Join Date: Feb 2009 Posts: 24,949 Thanks: 75 Thanked 4,306 Times in 4,273 Posts I don't get it. Why did you give this example: Code: ```if valoareTreceri=4 then valoare1=15*1.25*(0.3*(4-1)+1) = =15 * 1.25 * (1.9)= 35.62 if valoaretreceri=5 then valoare1=15*1.25*(0.3*(5-1)+1)= =15 *1.25* (2.2) = 41.25``` Which of course could be done without any "if"s as simply: Code: `valoare1=15*1.25*(0.3*(valoareTreceri-1)+1);` And then change your mind and give these: Code: ```if valoareTreceri=4 valoare1=f8+38 ... etc. ...``` Which is it? __________________ An optimist sees the glass as half full. A pessimist sees the glass as half empty. A realist drinks it no matter how much there is. Last edited by Old Pedant; 07-04-2013 at 01:36 AM..

 Bookmarks

 Tags java calculation

 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 01:18 PM.