Jump to content

Need some help with arithmetic in PHP (and some javascript)


Recommended Posts




I'm making a time laps calculator based off of the equation found http://americandslr.com/2010/10/time-lapse-calculator/ there. I'm completely done with the functional part of it. Now I need to worry about the aesthetic part of it.



Here is the code:


if (isset($_POST['filming'])) $hour = $_POST['filming'];
if (isset($_POST['framerate'])) $framerate = $_POST['framerate'];
if (isset($_POST['dtrt'])) $dtrt = $_POST['dtrt'];
$half = $hour * 3600;

$halftwo = $framerate * $dtrt;

$answer = $half / $halftwo;


<!DOCTYPE html>
<html lang='en'>
    <title>Timelapse Calculator</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
<div class="well span 5">
<form class="form-horizontal" method="POST">

<!-- Form Name -->
<legend><h1><center>Timelapse Calculator</h1></center><br></legend>

<!-- Text input-->
<div class="control-group">
  <label class="control-label" for="filming"><strong>Film Time (in hours)</strong></label>
  <div class="controls">
    <input id="filming" name="filming" type="text" placeholder="type here..." class="input-medium" required="">
    <p class="help-block">1 hour would be "1", 1 and a half hours would be "1.5" etc. </p>

<!-- Text input-->
<div class="control-group">
  <label class="control-label" for="framerate"><strong>Frame Rate</strong></label>
  <div class="controls">
    <input id="framerate" name="framerate" type="text" placeholder="type here..." class="input-medium" required="">
    <p class="help-block">How fast will it be presented?</p>

<!-- Text input-->
<div class="control-group">
  <label class="control-label" for="dtrt"><strong>Duration</strong></label>
  <div class="controls">
    <input id="dtrt" name="dtrt" type="text" placeholder="type here..." class="input-medium" required="">
    <p class="help-block">How long do you want the time lapse to last? <u>IN SECONDS</u></p>

<!-- Button -->
<div class="control-group">
  <label class="control-label" for="submit"></label>
  <div class="controls">
    <input type="submit" class="btn btn-primary btn-large" value="Submit"/>


<h2><center><strong><?php echo $answer . "  seconds between picture" ?></center></strong></h2>


  <script src="http://code.jquery.com/jquery.js"></script>
    <script src="js/bootstrap.min.js"></script>

(yes i'm using bootstrap)






Here is a screenshot of what it looks like before and after you submit:












Before submission: 


After submission:





1. how do I make it round to the nearest tenth? When I used "round($answer, 1);" it crashed my script. 


2. How can I make the "seconds between picture" only appear after you press submit?


Thanks, I'm a noob.



Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.