Jump to content

Search the Community

Showing results for tags 'calculation'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • W3Schools
    • General
    • Suggestions
    • Critiques
  • HTML Forums
    • CSS
  • Browser Scripting
    • JavaScript
    • VBScript
  • Server Scripting
    • Web Servers
    • Version Control
    • SQL
    • ASP
    • PHP
    • .NET
    • ColdFusion
    • Java/JSP/J2EE
    • CGI
  • XML Forums
    • XML
    • Schema
    • Web Services
  • Multimedia
    • Multimedia
    • FLASH

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL








Found 6 results

  1. Hello W3S! I'm on it again.... (lol). So lately i've been playing around with creating my very own calendar system where i can connect everything with the database somehow (this is for future purposes tho! for now i only wonna make the calculations and the view/design look great!). So if you could help with the part of the calculations, i would love that. This is my (WHOLE) PHP/FILE code so far: (a little messy) <?php // -> Default Date, Time & Timezone Setup // Timezone List: ( " http://php.net/manual/en/timezones.php " ) date_default_timezone_set('Europe/Copenhagen'); // set the default timezone to use. Available since PHP 5.1 if( ini_get('date.timezone') != 'Europe/Copenhagen' ){ ini_set( 'date.timezone', 'Europe/Copenhagen' ); } // _GET the Year and Month // $m = "m" = "Numeric representation of a month, with leading zeros" = "01 through 12" // $m = "n" = "Numeric representation of a month, without leading zeros" = "1 through 12" $y = (isset($_GET['year']) ? $_GET['year'] : date('Y')); // Year $m = (isset($_GET['month']) ? $_GET['month'] : date('n')); // Month // Months (ARRAY) // ( just like Jan,Feb,Mar,Apr in short format etc... ) $months_array = array( '1'=>'Januar', // Januar (DK), Jan/JAN (DK/ENG), January (ENG) '2'=>'Februar', // Februar (DK), Feb/FEB (DK/ENG), February (ENG) '3'=>'Marts', // Marts (DK), Mar/MAR (DK/ENG), March (ENG) '4'=>'April', // April (DK), Apr/APR (DK/ENG), April (DK/ENG) '5'=>'Maj', // Maj (DK), Maj/MAJ (DK), May/MAY (ENG), May (ENG) '6'=>'Juni', // Juni (DK), Jun/JUN (DK/ENG), June (ENG) '7'=>'Juli', // Juli (DK), Jul/JUL (DK/ENG), July (ENG) '8'=>'August', // August (DK), Aug/AUG (DK/ENG), August (DK/ENG) '9'=>'September', // September (DK), Sep/SEP (DK/ENG), September (DK/ENG) '10'=>'Oktober', // Oktober (DK), Okt/OKT (DK), Oct/OCT (ENG), October (ENG) '11'=>'November', // November (DK), Nov/NOV (DK/ENG), November (DK/ENG) '12'=>'December' // December (DK), Dec/DEC (DK/ENG), December (DK/ENG) ); // Monthly Days (ARRAY) // ( md_array = Monthly Days _ Array ) $md_array = array( '1'=>31, // Jan '2'=>28, // Feb '3'=>31, // Mar '4'=>30, // Apr '5'=>31, // Maj '6'=>30, // Jun '7'=>31, // Jul '8'=>31, // Aug '9'=>30, // Sep '10'=>31, // Okt '11'=>30, // Nov '12'=>31 // Dec ); // Monthly Days (CALCULATION) // ( md = Monthly Days _ Calculation ) $md_calculation = ($m==2 && $y%4==0) ? 29 : $md_array[$m]; // (NEEDS MORE DETAILS FOR LATER PURPOSES!) // Days (ARRAY) $days_array = array( '1'=>'Mandag', // Mandag (DK), Man/MAN (DK), Mon/MON (ENG), Monday (ENG) '2'=>'Tirsdag', // Tirsdag (DK), Tir/TIR (DK), Tue/TUE (ENG), Tuesday (ENG) '3'=>'Onsdag', // Onsdag (DK), Ons/ONS (DK), Wed/WED (ENG), Wednesday (ENG) '4'=>'Torsdag', // Torsdag (DK), Tor/TOR (DK), Thu/THU (ENG), Thursday (ENG) '5'=>'Fredag', // Fredag (DK), Fre/FRE (DK), Fri/FRI (ENG), Friday (ENG) '6'=>'Lørdag', // Lørdag (DK), Lør/LØR (DK), Sat/SAT (ENG), Saturday (ENG) '7'=>'Søndag' // Søndag (DK), Søn/SØN (DK), Sun/SUN (ENG), Sunday (ENG) ); // Monthly Start Day (?) // ( msd_date = Monthly Start Day _ Date ) $msd_date = $y.'-'.$m.'-01'; // Monthly Start Day (?) // ( msd_startday = Monthly Start Day _ Start Day ) $msd_startday = array_search( date( 'D', strtotime($msd_date) ), $days_array ); // Next And Previous Calculation Of Month And Year (CALCULATION) // napcomay_next_y = Next And Previous Calculation Of Month And Year _ Next _ Year // napcomay_next_m = Next And Previous Calculation Of Month And Year _ Next _ Month // napcomay_prev_y = Next And Previous Calculation Of Month And Year _ Prev _ Year // napcomay_prev_m = Next And Previous Calculation Of Month And Year _ Prev _ Month $napcomay_next_y=(($m+1)>12)?($y+1):$y; $napcomay_next_m=(($m+1)>12)?1:($m+1); $napcomay_prev_y=(($m-1)<=0)?($y-1):$y; $napcomay_prev_m=(($m-1)<=0)?12:($m-1); ?> <!DOCTYPE html> <!-- da == (DANSK / DANISH) --> <html lang="da"> <head> <!-- Required meta tags --> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <!-- Bootstrap CSS - V.4.5.2 --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css" integrity="sha384-JcKb8q3iqJ61gNV9KGb8thSsNjpSL0n8PARn9HuZOnIxN0hoP+VmmDGMN5t9UJ0Z" crossorigin="anonymous"> <!-- WWW TITLE --> <title>Kalender System - Version 1.0</title> </head> <body> <!-- DISPLAY YEARS AND YEAR PAGINATION --> <!-- display 5 previous and 5 next years of selected year --> <div class="container-fluid py-3"> <div class="row"> <div class="col-sm-12"> <nav> <ul class="pagination pagination-sm justify-content-center"> <!-- <li class="page-item"> <a class="page-link" href="#" aria-label="Previous"> <span aria-hidden="true">&laquo;</span> </a> </li> --> <?php for ($i=$y-5; $i<=$y+5; $i++){ $current_year = date("Y"); if( isset($_GET['year']) && $_GET['year'] == $i ) { echo ' <!-- <li class="page-item active" aria-current="page"> --> <li class="page-item active"> <span class="page-link"> '.$i.' <span class="sr-only">(nuværende år)</span> </span> </li> '; } else if( !isset($_GET['year']) && $i == $current_year ) { echo ' <!-- <li class="page-item active" aria-current="page"> --> <li class="page-item active"> <span class="page-link"> '.$i.' <span class="sr-only">(nuværende år)</span> </span> </li> '; } else { echo ' <li class="page-item"> <a class="page-link" href="index.php?year='.$i.'&month='.$m.'"> '.$i.' </a> </li> '; } } ?> <!-- <li class="page-item"> <a class="page-link" href="#" aria-label="Next"> <span aria-hidden="true">&raquo;</span> </a> </li> --> </ul> </nav> </div> </div> </div> <!-- DISPLAY MONTHS AND MONTHS PAGINATION --> <!-- display months --> <div class="container-fluid py-3"> <div class="row"> <div class="col-sm-12"> <nav> <ul class="pagination pagination-sm justify-content-center"> <!-- <li class="page-item"> <a class="page-link" href="#" aria-label="Previous"> <span aria-hidden="true">&laquo;</span> </a> </li> --> <?php foreach( $months_array AS $key => $value ){ echo ' <li class="page-item"> <a class="page-link" href="index.php?year='.$y.'&month='.$key.'"> '.$value.' </a> </li> '; } ?> <!-- <li class="page-item"> <a class="page-link" href="#" aria-label="Next"> <span aria-hidden="true">&raquo;</span> </a> </li> --> </ul> </nav> </div> </div> </div> <div class="container py-3"> <div class="row"> <div class="col-sm-12"> <header class="text-center"> <h1><?php echo $months_array[$m]; ?></h1> <h6>( <?php echo (isset($_GET['year']) ? $_GET['year'] : date("Y")); ?> )</h6> </header> </div> </div> <div class="row"> <div class="table-responsive"> <table class="table table-bordered table-striped table-hover"> <caption>TABLE CAPTION</caption> <thead> <tr class="text-center"> <!-- <th scope="col">UGE</th> <th scope="col">MAN</th> <th scope="col">TIR</th> <th scope="col">ONS</th> <th scope="col">TOR</th> <th scope="col">FRE</th> <th scope="col">LØR</th> <th scope="col">SØN</th> --> <th scope="col">UGE</th> <?php // display days foreach ( $days_array AS $key => $value ){ echo '<th scope="col">'.$value.'</th>'; } ?> </tr> </thead> <tbody> <!-- <tr> <th scope="row">1</th> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> </tr> <tr> <th scope="row">2</th> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> </tr> <tr> <th scope="row">3</th> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> </tr> <th scope="row">4</th> <td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td>6</td> <td>7</td> </tr> --> <tr> <?php for( $i=0; $i<($md_calculation+$msd_startday); $i++ ){ $day = ( $i - $msd_startday + 1 <= 9 ) ? '0'.( $i - $msd_startday + 1 ) : $i - $msd_startday + 1 ; echo ( $i < $msd_startday ) ? '<td></td>' : '<td>'.$day.'</td>' ; echo ( $i %7 == 0 ) ? '</tr><tr>' : '' ; } ?> </tr> </tbody> <tfoot> <tr class="text-center"> <td colspan="8">TABLE FOOT</td> </tr> </tfoot> </table> </div> </div> </div> <!-- Optional JavaScript --> <!-- jQuery first, then Popper.js, then Bootstrap JS --> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js" integrity="sha384-B4gt1jrGC7Jh4AgTPSdUtOBvfO8shuf57BaghqFfPlYxofvL8/KUEfYiJOMMV+rV" crossorigin="anonymous"></script> </body> </html> Note that what im trying to do here, is to create a simple PHP Based Calendar dynamicly working. Right now im just trying to show some simple stuff so i know a little about how everything works. I watched this answer online: ( how-to-create-a-dynamic-calendar-with-mysql-php-etc ) - and it worked great! Then i started to tear stuff here and there apart, so i might understand it a little better and try to improve it a little bit. Now, i am showing in the HTML part successfully things like years, months... but the calendar itself i have a little trouble with. What i wanna try to do, is to also at one point, show stuff like (WEEKS)... and im talking weeks of the year here and what current week we are in. So that means in my code where i show the calendar, this code: for( $i=0; $i<($md_calculation+$msd_startday); $i++ ){ $day = ( $i - $msd_startday + 1 <= 9 ) ? '0'.( $i - $msd_startday + 1 ) : $i - $msd_startday + 1 ; echo ( $i < $msd_startday ) ? '<td></td>' : '<td>'.$day.'</td>' ; echo ( $i %7 == 0 ) ? '</tr><tr>' : '' ; } i have to somehow figure out how to calculate the weeks into the days, somehow giving the days an "offset" with "1" so that they do NOT overwrite somehow the weeks column in the HTML TABLE im creating the calendar on... i have tried to explain a little bit of what im trying and im still trying to figure out what everything means so that i can comment stuff out here and there for myself (for later purposes etc). So if you guys got any idea for the weeks/days part regarding the calendar, i would love the help i could get! ❤️ Thanks in advance NOTE: The full code i shared, you can copy/paste etc... its a full code with full design and everything based on bootstrap css library... just make sure to be online so it works If you got questions or i need to explain a little bit more into details, please reply and i will do my best. Thanks.
  2. I'm trying to create a form that allows for calculation of metabolic rate. There is an if,then statement related to gender (formula changes if female vs male) I'd also like the result to be targeted to a specific part of the page (anchor). Ideally a new section can appear (maybe need to link a new page?) to provide further details Below is my code, any help would be so appreciated!! <head> <style> body { font: 15px gothic, sans-serif; letter-spacing: 1px; } input { width: 100%; } input[type=number] { border: none; border-bottom: 1px solid grey; } input[type=button], input[type=submit], input[type=reset] { background-color: #ddcecb; border: none; -moz-border-radius: 5px; -webkit-border-radius: 5px; color: #95483e; padding: 16px 32px; text-decoration: none; letter-spacing: 1px; margin: 4px 2px; #submit:hover { border: none; background: #d2d1d1; box-shadow: 0px 0px 1px #777; }} input[type=text]:focus { border: 1px solid #555; } .form-inline label { margin: 5px 10px 5px 0; } @media (max-width: 800px) { .form-inline input { margin: 10px 0; } .form-inline { flex-direction: column; align-items: stretch; } </style> </head> <form name="RMRcalc"> weight (kg) : <input type="number" name="weight" autofocus><br><br> height (cm): <input type="number" name="height"> <br><br> age (years): <input type="number" name="age"> <br><br> activity Level: <select name="activity" margin=5px > <option value="1.2">sedentary (1-2x/week)</option> <option value="1.3">low (2-3x/week)</option> <option value="1.4">moderate (3-4x/week)</option> <option value="1.6">high (5+x/week)</option> </select> <br><br> female <input type="radio" name="gender" value="female" checked> <br> male <input type="radio" name="gender" value="male"> <br> <input type="submit" value="Calculate" id="calculate" onclick="RMRCalc ()" target="results"> <br><br> <script type="text/javascript"> "use strict" function RMRCalc () { var weight = document.getElementById ("weight").value; var height = document.getElementById("height").value; var age = document.getElementById("age").value; var activity = document.getElementById("activity").value; if (gender="female") var RMR = (10*weight) + (6.25*height) - (5*age) -161; document.getElementById("RMR").innerHTML=RMR; else var RMR = (10*weight) + (6.25*height) - (5*age) +5; document.getElementById("RMR").innerHTML=RMR; } </script> </form> <p><a name="results"> Your Daily Caloric Requirements: <div id ="RMR"></div> </a></p> <br> <p> Did you know that Thank you!!
  3. Hi there. I have been wandering around the tutorials and examples and trying to get a simple variable calculation done in the html code below but can't seem to get it right. The html code below works fine now to create a button for PayPal and submit an order. The problem is, I need the "amount_2" to actually be calculated to 2% of "amount_1". a simple, "amount_2" = "amount_1" * 0.02 This is to allow us to take payment with PayPal and add their merchant fees. Can anyone help please :-) ------------------------------------------ <form action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="hidden" name="cmd" value="_cart"> <input type="hidden" name="upload" value="1"> <input type="hidden" name="business" value="accounts@freelanceswitch.com"> <input type="hidden" name="currency_code" value="AUD"> <input type="hidden" name="item_name_1" value="My Invoice"> <input type="hidden" name="amount_1" value="1885.00"> <input type="hidden" name="item_name_2" value="Merchant Fee"> <input type="hidden" name="amount_2" value="9999"> <input type="image" src="http://www.paypal.com/en_US/i/btn/x-click-but01.gif" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"> </form> ------------------------------------------
  4. Does anybody know how this calculation can be changed into KG's not llb's it calculates BMI //BMI Form Validation... $('form.dt-sc-bmi-frm').each(function(){ $(this).validate({ rules: { txtfeet: { required: true }, txtinches: { required: true }, txtlbs: { required: true } }, errorPlacement: function(error, element) { } }); }); //BMI Calculation... $('form[name=frmbmi]').submit(function(){ var This = $(this); if(This.valid()) { var fet = This.find('input[name=txtfeet]').val(); var inc = This.find('input[name=txtinches]').val(); var tinc = ( parseInt(fet) * 12 ) + parseInt(inc); var lbs = This.find('input[name=txtlbs]').val(); var bmi = ( parseFloat(lbs) / (tinc * tinc) ) * 703; This.find('input[name=txtbmi]').val(parseFloat(bmi).toFixed(1)); } return false; }); //BMI View... if($("a.fancyInline").length) { $("a.fancyInline").fancybox({ scrolling: 'no', width: 'auto', height: 'auto' }); }
  5. Hello everyone, I've an application which uses xml form for data entry. I was wondering if is possible to make calculation (mainly additions and subtraction)? <?xml version="1.0"?><items><item type="settings" position="label-top"/> <item type="label" label="Edit report details here." /> <item type="label" label="Date"/><item type="calendar" dateformat="%d/%m/%Y" validate="notEmpty" required="true" name="date" bind="date" label="Date" offsetLeft="15"/><item type="input" name="admin" bind="admin" label="Admin" offsetLeft="15"/> <item type="label" label="Sales"/> <item type="input" name="others" bind="others" label="Others" offsetLeft="15"/><item type="input" name="internet" bind="internet" label="Internet" offsetLeft="15"/><item type="input" name="topup" bind="topup" label="Top Up" offsetLeft="15"/><item type="input" name="phcard" bind="phcard" label="Phone Cards" offsetLeft="15"/><item type="input" name="phcalls" bind="phcalls" label="Phone Calls" offsetLeft="15"/> <item type="input" name="bustickets" bind="bustickets" label="Bus Tickets" offsetLeft="15"/> <item type="input" readonly="true" name="totalin" bind="totalin" label="Total In" offsetLeft="15"/> <item type="label" label="Expenses & Goods"/> <item type="input" name="expenses" bind="expenses" label="Expenses" offsetLeft="15"/><item type="input" name="goods" bind="goods" label="Goods" offsetLeft="15"/><item type="input" name="goodsdetails" bind="goodsdetails" label="Goods Details" offsetLeft="15"/><item type="input" readonly="true" name="balance" bind="balance" label="Balance" offsetLeft="15"/><item type="input" name="till" bind="till" label="Till" offsetLeft="15"/><item type="input" name="cash" bind="cash" label="Cash" offsetLeft="15"/><item type="input" name="debits" bind="debits" label="Debits" offsetLeft="15"/> <item type="input" readonly="tru" name="extra_short" bind="extra_short" label="Extra/Short" offsetLeft="15"/> <item type="button" xcommand="save" value="Submit" offsetTop="15"/> <item type="label" label="" offsetTop="15"/></items> What do you guys think?
  6. Hi I'm attempting to use XSL to caluclate the grand total for two invnoices, whilst the calculation provides a number, on the first invoice's grand total, the number is off by 0.05 and on the second invoice there is "000000000001" after the correct first two decimal places. This is the XSL code I'm using to make the calculation:<td style="text-align:center;"> <strong><xsl:value-of select="sum(//item_price)" /></strong> </td> CaesarII
  • Create New...