Hi,
I have a table that I can add a new row when I press a button. Each row must have a random number in his first column. However, I’m not sure how to include my number in this situation
function ajoutLigne()
{
let identifiant = Math.floor((Math.random() * 10000) + 1);
let titre = document.getElementById('titre').value ;
let nombre = document.getElementById('nombre').value ;
let directeur = document.getElementById('directeur').value ;
let tableau = document.getElementById('tableau');
let tableauLongueur =(tableau.rows.length);
let ligne = tableau.insertRow(tableauLongueur).outerHTML="<tr id='ligne"+tableauLongueur+"'>" +
"<td class='identifiantRandom'> identifiant </td>" +
"<td id='episodeTitre"+tableauLongueur+"'>"+titre+"</td>" +
"<td id='episodeNombre"+tableauLongueur+"'>"+nombre+"</td>" +
"<td id='episodeDirecteur"+tableauLongueur+"'>"+directeur+"</td>" +
"<td>" +
"<input type='button' id='modifierBtn"+tableauLongueur+"' value='Modifier' class='modifier' onclick='modifierLigne("+tableauLongueur+")'> " +
"<input type='button' id='validerBtn"+tableauLongueur+"' value='Valider' class='valider' onclick='validerLigne("+tableauLongueur+")'> " +
"<input type='button' value='Supprimer' class='supprimer' onclick='supprimerLigne("+tableauLongueur+")'>" +
"<input type='button' id='annulerBtn1' value='Annuler' class='annuler' onclick='annulerLigne("+tableauLongueur+")'> " +
"</td" +
"></tr>";
My variable identifiant is not added in a new column. How can I do that?
Thanks you.