Click here to Skip to main content
14,602,124 members

JavaScript

 
GeneralRe: Javascript function error. Pin
jkirkerx12-Jun-20 8:47
professionaljkirkerx12-Jun-20 8:47 
GeneralRe: Javascript function error. Pin
and180y12-Jun-20 10:48
Memberand180y12-Jun-20 10:48 
GeneralRe: Javascript function error. Pin
jkirkerx12-Jun-20 11:11
professionaljkirkerx12-Jun-20 11:11 
GeneralRe: Javascript function error. Pin
jkirkerx12-Jun-20 10:17
professionaljkirkerx12-Jun-20 10:17 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 5:57
Memberand180y13-Jun-20 5:57 
GeneralRe: Javascript function error. Pin
Richard MacCutchan13-Jun-20 6:31
mveRichard MacCutchan13-Jun-20 6:31 
GeneralRe: Javascript function error. Pin
and180y13-Jun-20 11:48
Memberand180y13-Jun-20 11:48 
GeneralRe: Javascript function error. Pin
jkirkerx13-Jun-20 7:36
professionaljkirkerx13-Jun-20 7:36 
You got it wrong ... You are fresh at this Wink | ;)
I can't test this at the moment, but it should work.
I hope it does.
<script>    

function calcTime() {

  // Make references to input elements
  const time = document.getElementById("time"),
    current = document.getElementById("current"),<br />
    tier1 = document.getElementById ("tier1"),
    tier2= document.getElementById ("tier2"),
    breakEven = document.getElementById("breakEven"),
    results = document.getElementById("results");

  // Get the element values, convert to number/float
  // By default, values are strings, and don't do math well.
  let t = parseFloat(time.value);
  let c = parseFloat(current.value);

  // Perform the equation
  let bE = t * c;

  // Output the equation to the span element, remove the comments below
  console.log("breakEven=", bE); // Diagnostics, hit F12 on your keyboard and select console
  results.innerHTML = bE.toString(); // innerHTML is for a span tag, value is textbox
}
</script>

<div class='col-sm-2 mb-1'>
  <input type='number' id='time' class='form-control' data-calc='time' placeholder='Minutes Allocated' tabindex='2'>
</div>
<div class='col-sm-2 mb-2'>
  <input type='text' id='current' class='form-control form-output' data-calc='current' value='£0.00' tabindex='-1'>
</div>
<div class='col-sm-2 mb-2'>
  <input type='text' id='breakEven' class='form-control form-output' data-calc='breakeven' value='£0.00' readonly tabindex='-1'>
</div>
<div class='col-sm-2 mb-2'>
  <input type='text' id='tier1' class='form-control form-output' data-calc='tier1' value='£0.00' readonly tabindex='-1'>
</div>
<div class='col-sm-2 mb-2'>
  <input type='text' id='tier2' class='form-control form-output' data-calc='tier2' value='£0.00' readonly tabindex='-1'>
</div>
<div class="row col-12">
   <button type="button" onBlur="calcTime()">Calculate</button>
</div>
<div class="row col-12">
  <span id="results">0</span> 
</div>
If it ain't broke don't fix it
Discover my world at jkirkerx.com

GeneralRe: Javascript function error. Pin
and180y13-Jun-20 11:47
Memberand180y13-Jun-20 11:47 
QuestionJavaScript slide show works bad on the first page load Pin
Hypnonis8-Jun-20 20:03
MemberHypnonis8-Jun-20 20:03 
AnswerRe: JavaScript slide show works bad on the first page load Pin
Richard Deeming8-Jun-20 22:30
mveRichard Deeming8-Jun-20 22:30 
GeneralRe: JavaScript slide show works bad on the first page load Pin
Hypnonis9-Jun-20 6:33
MemberHypnonis9-Jun-20 6:33 
QuestionJSON object not showing values.. Can someone help Pin
Member 35640766-Jun-20 4:33
MemberMember 35640766-Jun-20 4:33 
GeneralRe: JSON object not showing values.. Can someone help Pin
Richard MacCutchan7-Jun-20 0:50
mveRichard MacCutchan7-Jun-20 0:50 
QuestionPyramid array Pin
Girardi.E30-May-20 0:48
MemberGirardi.E30-May-20 0:48 
AnswerRe: Pyramid array Pin
Richard MacCutchan30-May-20 1:15
mveRichard MacCutchan30-May-20 1:15 
AnswerRe: Pyramid array Pin
DerekT-P30-May-20 2:30
professionalDerekT-P30-May-20 2:30 
Questionidentify each node with its Id Pin
vikas@prajaktasoftware.com19-May-20 8:57
Membervikas@prajaktasoftware.com19-May-20 8:57 
SuggestionRe: identify each node with its Id Pin
ZurdoDev19-May-20 9:39
mveZurdoDev19-May-20 9:39 
QuestionReturn negative number as 0 Pin
and180y18-May-20 1:46
Memberand180y18-May-20 1:46 
AnswerRe: Return negative number as 0 Pin
Richard MacCutchan18-May-20 2:05
mveRichard MacCutchan18-May-20 2:05 
GeneralRe: Return negative number as 0 Pin
and180y18-May-20 2:27
Memberand180y18-May-20 2:27 
GeneralRe: Return negative number as 0 Pin
Richard MacCutchan18-May-20 2:40
mveRichard MacCutchan18-May-20 2:40 
AnswerRe: Return negative number as 0 Pin
Richard Deeming18-May-20 5:43
mveRichard Deeming18-May-20 5:43 
GeneralRe: Return negative number as 0 Pin
and180y18-May-20 13:10
Memberand180y18-May-20 13:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.