add values of 5 text boxes and show the esult in 6th tetbo on the keypress vent of 5 th textbox

19
May 18, 2019, at 3:00 PM

i have 6 text boxes with id a,b,c,d,e,f.out of these i enter value for 5.i

want to get result like a+b+max(c,d,e) in 6th text box on the keypress event

of 5 th textbox.

i write code in javascipt but it doesnt work

function max_sum() {
    var p = document.getElementById('p').value;
    var c = document.getElementById('c').value;
    var b = document.getElementById('b').value;
    var m = document.getElementById('m').value;
    var cs = document.getElementById('cs').value;
    var s = Math.max(b,m,cs);
    var total = parseInt(p) + parseInt(c)+ parseInt(s)
    if (!isNaN(total)) {
        document.getElementById('total').value = total;
    }
}

i call my function here

<td width="69" style="text-align: center" colspan="1">
    <input name="cs" type="text" class="txtm" id="cs" size="6" required="required" onkeypress="return MoveNext('total', event.keyCode);,max_sum();"/>
</td>
Answer 1

Most likely, you JS console contains Uncaught ReferenceError: max_sum is not defined.

Assign your max_sum function to global variable:

window.max_sum = function() {
   //...
}
READ ALSO
react-apollo Server Side Rendering

react-apollo Server Side Rendering

Disclaimer: I saw many other questions on SO which sound the sameBut no, this question and its context, everything is different

43
How detect window closed (new tab) in Vue?

How detect window closed (new tab) in Vue?

Need watch if that window open or closed

17
How to animate circular progress bar on page scroll down

How to animate circular progress bar on page scroll down

I have a circular progress bar that animates when the page loads, but I want it to animate when the user scrolls down to it, as it will be in the middle of the pageRight now if the page loads, the user does not see the animation

13
Adding a Popup box for Winner of Game

Adding a Popup box for Winner of Game

I have been trying to add a popup box for my rock paper scissors game so that the program will display the winner when the game is overI have a function file and a file with the main code

52