javascript – How to add the inscription, the name and the average to the table?

HTML




    
    
    


    
    
    
        
        
        
    
    
        

AVERAGE















Elements in the table:

Registration name Average Remove

JS

var1 = 1;
var index = parseInt (val1);

add () {function
average-total var = 0;
var inscriptions = document.getElementById ("registration"). value;
var name = document.getElementById ("name"). value;
var p1 = document.getElementById ("p1"). value;
var p2 = document.getElementById ("p2"). value;
var p3 = document.getElementById ("p3"). value;

average = (parseFloat (p1) + parseFloat (p2) + parseFloat (p3)) / 3;

average var = parseFloat (promediototal);
var prom = document.getElementById ("content");
var parrafo1 = document.createElement ("p");
var text1 = document.createTextNode (index + ".- Registration:" + registration + "Student:" + name + "Average:" + parseInt (promediototal));

index = index + 1;

parrafo1.appendChild (text1);
prom.appendChild (paragraph1);

}

$ (document) .ready (function () {
// we get the value of the input

$ (# Add) & # 39; click (function () {
var name = document.getElementById ("name"). value;
var lastname = document.getElementById ("registration"). value;
var cedula = document.getElementById ("average"). value;
var i = 1; // counter to assign an identifier to the button that will clear the line
row = & # 39; row& # 39; + name + & # 39;& # 39; + + & # 39;& # 39; + cedula + & # 39;& # 39 ;; // that would be what the line would contain

i ++;

$ (# Mytable tr: first & # 39;). after (row);
$ ("# added"). text (""); // this statement also deletes the div so that it does not accumulate
var nFilas = $ ("# mytable tr"). length;
$ ("# added"). append (nFiles - 1);
// remain 1 to not count the header line
document.getElementById ("Name"). value = "";
document.getElementById ("Average"). value = "";
document.getElementById ("Registration"). value = "";
document.getElementById ("Matricla"). focus ();
});
$ (document) .on ('click', '.btn_remove', function () {
var button_id = $ (this) .attr ("id");
// by clicking, we get the id of the button
$ (# Row & # 39; + button_id + & # 39;)) .remove (); // delete the line
// clean it so that it repeats the lines of the table
$ ("# added"). text ("");
var nFilas = $ ("# mytable tr"). length;
$ ("# added"). append (nFiles - 1);
});
}

function message () {
varotedotal;

var inscriptions = document.getElementById ("registration"). value;
var name = document.getElementById ("name"). value;
var p1 = document.getElementById ("p1"). value;
var p2 = document.getElementById ("p2"). value;
var p3 = document.getElementById ("p3"). value;

average = (parseFloat (p1) + parseFloat (p2) + parseFloat (p3)) / 3;

average var = parseFloat (promediototal);

alert ("Registration:" + registration + " n" + "Student:" + name + " nEmployment:" + average);
}