8 Replies - 1237 Views - Last Post: 24 September 2012 - 12:27 PM

#1 borninlyoko  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 350
  • Joined: 03-December 09

Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 01:24 PM

Hey, tried to make a calculator for a specific purpose, but had some issues due to my lack of sleep for the past few days. Anyone feel like helping?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Flash Player Bitcoin Miner Calculator</title>
    <script type="text/javascript">
        calculate(){
            var users = document.getElementById('musers').value;
            var timespent = document.getElementById('timespent').value;
            var btcps = 0.000000000617283950;
            var timeday = timespent/30;
            var userday = users/30;
            var calcresult = userday*timeday*btcps + 'BTC';
            document.getElementById('result').innerHTML = calcresult;
       }
    </script>
  </head>
  <body>
    <form action="" id="flashminer">
      <label for="musers">Monthly Users</label><input type="text" id="musers"><br>
      <label for="timespent">Monthly Time Spent (in seconds)</label><input type="text" id="timespent"><br>
      <input type="button" value="Calculate" onclick="calculate()"><br>
      <input type="text" id="result" disabled="disabled" value="0.00BTC">
    </form>
  </body>
</html>


The main issue that I have is that absolutely nothing happens.

This post has been edited by borninlyoko: 21 September 2012 - 01:26 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Simple Javascript Calculator Not Completing

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9286
  • View blog
  • Posts: 34,802
  • Joined: 12-June 08

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 01:45 PM

Looks like the same code found here. Where was your input in this?
Was This Post Helpful? 0
  • +
  • -

#3 borninlyoko  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 350
  • Joined: 03-December 09

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 01:56 PM

View Postmodi123_1, on 21 September 2012 - 01:45 PM, said:

Looks like the same code found here. Where was your input in this?


It is the same code, I posted a comment in the OP code there showing that it was my code from the beginning!

Sorry about that :P I forgot about the plagiarism issues here.

This post has been edited by borninlyoko: 21 September 2012 - 01:57 PM

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9286
  • View blog
  • Posts: 34,802
  • Joined: 12-June 08

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 02:04 PM

What?
Was This Post Helpful? 0
  • +
  • -

#5 ThrowsException  Icon User is offline

  • D.I.C Head

Reputation: 33
  • View blog
  • Posts: 83
  • Joined: 21-February 12

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 02:12 PM

Have you tried debugging this in chrome or firefox?
Was This Post Helpful? 1
  • +
  • -

#6 borninlyoko  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 350
  • Joined: 03-December 09

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 02:22 PM

View Postmodi123_1, on 21 September 2012 - 02:04 PM, said:

What?


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Flash Player Bitcoin Miner Calculator</title>
    <!--Also Posted to DreamInCode for help, username borninlyoko, verification for moderator modi123_1-->
    <script type="text/javascript">
        calculate(){
            var users = document.getElementById('musers').value;
            var timespent = document.getElementById('timespent').value;
            var btcps = 0.000000000617283950;
            var timeday = timespent/30;
            var userday = users/30;
            var calcresult = userday*timeday*btcps + 'BTC';
            document.getElementById('result').innerHTML = calcresult;
       }
    </script>


Specifically:
<!--Also Posted to DreamInCode for help, username borninlyoko, verification for moderator modi123_1-->

Was This Post Helpful? 0
  • +
  • -

#7 borninlyoko  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 350
  • Joined: 03-December 09

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 02:33 PM

View PostThrowsException, on 21 September 2012 - 02:12 PM, said:

Have you tried debugging this in chrome or firefox?

Yes I did try that, thank you though for the suggestion.
Was This Post Helpful? 0
  • +
  • -

#8 Sho Ke  Icon User is online

  • D.I.C Regular
  • member icon

Reputation: 110
  • View blog
  • Posts: 250
  • Joined: 13-October 11

Re: Simple Javascript Calculator Not Completing

Posted 21 September 2012 - 02:54 PM

Usually the first thing you should do when debugging is look at the error console. If you had done that, you would've seen this right as the page loads(using Firefox's error console)

Quote

[16:52:05.825] SyntaxError: missing ; before statement @ file:///<directory here>


It refers to this line:
        calculate(){



What's that supposed to do?
http://www.quirksmod...s/function.html

Additionally, the text inside an input field is its value, not innerHTML.

This post has been edited by Sho Ke: 21 September 2012 - 03:20 PM

Was This Post Helpful? 2
  • +
  • -

#9 borninlyoko  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 7
  • View blog
  • Posts: 350
  • Joined: 03-December 09

Re: Simple Javascript Calculator Not Completing

Posted 24 September 2012 - 12:27 PM

View PostSho Ke, on 21 September 2012 - 02:54 PM, said:

Usually the first thing you should do when debugging is look at the error console. If you had done that, you would've seen this right as the page loads(using Firefox's error console)

Quote

[16:52:05.825] SyntaxError: missing ; before statement @ file:///<directory here>


It refers to this line:
        calculate(){



What's that supposed to do?
http://www.quirksmod...s/function.html

Additionally, the text inside an input field is its value, not innerHTML.


Ah, now I feel like an idiot :P I forgot to declare the damned function! Thank you very much :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1