<!doctype html>
<!-- Name:Thomas Smith
     Student No.00048668 -->
<!-- ============================================================== -->
 <meta charset="utf-8">
   <title>Time Remaining</title>
   <h1 style="text-align:left">How Much Time Until?</h1>
   <p>Enter the date: <input type="text" id="endBox" size=16 value=''></p>
   <input type="button" value="Find Out" style="width:130px;" onclick="javascript:TimeUntil();"/>
   <div id="outputDiv"></div>
      <script type="text/javascript" src="time.js"></script>
      <script type="text/javascript">
function TimeUntil()
  var seconds = SecondsUntil('endBox');
  var time = SecondsToString(answer);

  return time;
function SecondsToString(seconds)
  var days = Math.floor(seconds / (24*60*60));
  seconds = seconds - days*(24*60*60);
  var hours = Math.floor(seconds / (60*60));
  seconds = seconds - hours*(60*60);
  var minutes = Math.floor(seconds / 60);
  seconds = seconds - minutes*60;

  var answer = days + ' days, ' + hours + ' hours, ' + minutes + ' minutes, ' +
         seconds + ' seconds';
function SecondsUntil(endBox)
  var goalDate = new Date(endBox);
  var current = new Date();
  var diff = Math.floor((goalDate - current)/1000);
 document.getElementById('outputDiv')innerHTML = "Time left is " + diff;   
<p>Enter the date: <input type="date" id="endBox" size='16'></p>

Hi Thomas_31,

There are numbers of errors in your script. Bu the obvious one in which you presently batteling with occurs on line 22 of the OP.
You are taking the vaule of text in the textbox you provided, but you are not assigning it to any variable, hence it taken it into void like. So you probably want to assign that to a variable like so: var myValue = document.getElementById('endBox').value; and then pass that variable to your function SecondsUntil like so var seconds = SecondsUntil(myValue); and not what you are presently doiing.

Secondly, you will not also get display like you wanted because instead of doing this document.getElementById('outputDiv').innerHTML = "Time left is " + diff; you are doing this document.getElementById('outputDiv')innerHTML = "Time left is " + diff; Check line 45. It is .innerHTML, you missed the ..

Lastly, what is the scope of your variable answer used in line 24?

Please check these and some other design issues.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.