Results 1 to 2 of 2
  1. #1
    shdale is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Default I need 2x decimal points in result

    Hello, I have this java code but it calculates a whole, rounded number. I need it to be a decimal (x2). Can you help?
    <script type="text/javascript">
    function calculateText()
    {
    var op1=document.getElementById('Age02');
    var op2=document.getElementById('Girl35');
    var op3=document.getElementById('Boy35');
    var op4=document.getElementById('Girl610');
    var op5=document.getElementById('Boy610');
    var op6=document.getElementById('Age11');
    var op7=document.getElementById('Guest');
    var op8=document.getElementById('VIP');
    var op9=document.getElementById('School');
    var op10=document.getElementById('3DFilm');
    var op11=document.getElementById('BFast');
    var op12=document.getElementById('PNGift');
    var op13=document.getElementById('PStand');
    var op14=document.getElementById('PLrg');
    var op15=document.getElementById('PReP');
    var op16=document.getElementById('KyMg');
    var op17=document.getElementById('SnwGlb');
    var op18=document.getElementById('PBbl');
    var op19=document.getElementById('USB');
    var op20=document.getElementById('SantaL');
    var op21=document.getElementById('SantaK');
    var op22=document.getElementById('FreeP');
    var op23=document.getElementById('PUpgrd');
    var op24=document.getElementById('StaffP');
    var op25=document.getElementById('CompEntry');
    var op26=document.getElementById('241');
    var op27=document.getElementById('50Percent');
    var op28=document.getElementById('Voucher');

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

    if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
    if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;
    if(op3.value=="" || op3.value!=parseFloat(op3.value)) op3.value=0;
    if(op4.value=="" || op4.value!=parseFloat(op4.value)) op4.value=0;
    if(op5.value=="" || op5.value!=parseFloat(op5.value)) op5.value=0;
    if(op6.value=="" || op6.value!=parseFloat(op6.value)) op6.value=0;
    if(op7.value=="" || op7.value!=parseFloat(op7.value)) op7.value=0;
    if(op8.value=="" || op8.value!=parseFloat(op8.value)) op8.value=0;
    if(op9.value=="" || op9.value!=parseFloat(op9.value)) op9.value=0;
    if(op10.value=="" || op10.value!=parseFloat(op10.value)) op10.value=0;
    if(op11.value=="" || op11.value!=parseFloat(op11.value)) op11.value=0;
    if(op12.value=="" || op12.value!=parseFloat(op12.value)) op12.value=0;
    if(op13.value=="" || op13.value!=parseFloat(op13.value)) op13.value=0;
    if(op14.value=="" || op14.value!=parseFloat(op14.value)) op14.value=0;
    if(op15.value=="" || op15.value!=parseFloat(op15.value)) op15.value=0;
    if(op16.value=="" || op16.value!=parseFloat(op16.value)) op16.value=0;
    if(op17.value=="" || op17.value!=parseFloat(op17.value)) op17.value=0;
    if(op18.value=="" || op18.value!=parseFloat(op18.value)) op18.value=0;
    if(op19.value=="" || op19.value!=parseFloat(op19.value)) op19.value=0;
    if(op20.value=="" || op20.value!=parseFloat(op20.value)) op20.value=0;
    if(op21.value=="" || op21.value!=parseFloat(op21.value)) op21.value=0;
    if(op22.value=="" || op22.value!=parseFloat(op22.value)) op22.value=0;
    if(op23.value=="" || op23.value!=parseFloat(op23.value)) op23.value=0;
    if(op24.value=="" || op24.value!=parseFloat(op24.value)) op24.value=0;
    if(op25.value=="" || op25.value!=parseFloat(op25.value)) op25.value=0;
    if(op26.value=="" || op26.value!=parseFloat(op26.value)) op26.value=0;
    if(op27.value=="" || op27.value!=parseFloat(op27.value)) op27.value=0;
    if(op28.value=="" || op28.value!=parseFloat(op28.value)) op28.value=0;

    result.value=0;
    result.value=parseInt(result.value);
    result.value=parseInt(result.value)+parseInt(op1.v alue*5)+parseInt(op2.value*5)+parseInt(op3.value*5 )+parseInt(op4.value*5)+parseInt(op5.value*5)+pars eInt(op6.value*5)+parseInt(op7.value*0)+parseInt(o p8.value*8.50)+parseInt(op9.value*3.75)+parseInt(o p10.value*0)+parseInt(op11.value*10)+parseInt(op12 .value*5)+parseInt(op13.value*3)+parseInt(op14.val ue*4)+parseInt(op15.value*2)+parseInt(op16.value*4 )+parseInt(op17.value*5)+parseInt(op18.value*3)+pa rseInt(op19.value*5)+parseInt(op20.value*4)+parseI nt(op21.value*3)+parseInt(op22.value*0)+parseInt(o p23.value*1)+parseInt(op24.value*0)+parseInt(op25. value*0)+parseInt(op26.value*4)+parseInt(op27.valu e*2)-parseInt(op28.value);
    }

    </script>

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,879
    Rep Power
    8

    Default Re: I need 2x decimal points in result

    Javascript != Java.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 1
    Last Post: 08-11-2011, 10:46 AM
  2. Struts 2 error : No result defined for action / result
    By sameerk in forum Web Frameworks
    Replies: 1
    Last Post: 05-17-2011, 10:15 AM
  3. Decimal to binary, octal to decimal
    By matejm1994 in forum New To Java
    Replies: 3
    Last Post: 12-26-2010, 09:59 AM
  4. Percentage/decimal points?
    By Exhonour in forum New To Java
    Replies: 6
    Last Post: 01-16-2009, 10:35 PM
  5. Replies: 2
    Last Post: 08-24-2008, 12:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •