Jump to content

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


Fish181

Recommended Posts

Hi!

 

 

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:

<?php

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'>
  <head>
    <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">
  </head>
  <body>
  
<div class="well span 5">
  
<form class="form-horizontal" method="POST">
<fieldset>

<!-- 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>
  </div>
</div>

<!-- 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>
  </div>
</div>

<!-- 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>
  </div>
</div>

<!-- 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"/>
  </div>
</div>


</fieldset>
</form>

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

</div>


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

(yes i'm using bootstrap)

 

 

 

 

 

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

 

 

 

 

 

 

 

 

 

 

 

Before submission: 

http://gyazo.com/361d109f0af010fcda4d90288b338566

After submission:

http://gyazo.com/cf1c2c2089af3f6b4bf349aeab7fc1d4

 

 

 

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.

 

Fisher

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.