Click here to Skip to main content
14,664,730 members
Home » Discussions » JavaScript
   

JavaScript

 
JokeRe: Javascript function error. Pin
DerekT-P11-Jun-20 2:26
professionalDerekT-P11-Jun-20 2:26 
AnswerRe: Javascript function error. Pin
jkirkerx12-Jun-20 7:57
professionaljkirkerx12-Jun-20 7:57 
GeneralRe: Javascript function error. Pin
and180y12-Jun-20 8:33
Memberand180y12-Jun-20 8:33 
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 
Have added some more elements (not in use at present) but still not getting the breakeven to calculate.

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


<script>
	<button type="button" onBlur="calcTime()">Calculate</button>

function calcTime() {

  // Make references to input elements
  const time = document.getElementById("timeAllowed"),
    current = document.getElementById("currentCharge"),
    breakEven = document.getElementById("breakEven"),
    tier1 = document.getElementById ("tier1"),
	tier2= document.getElementById ("tier2");

  // 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
  breakEven.innerHTML = bE.toString();

}


modified 13-Jun-20 12:43pm.

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

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.