How to pick up innerHTML value

Asked

Viewed 66 times

0

I want to take two innerHTML values and split

   function adicionaLinha(idTabela) {

                var tabela = document.getElementById(idTabela);
                var numeroLinhas = tabela.rows.length;
                var linha = tabela.insertRow(numeroLinhas);
                var celula1 = linha.insertCell(0);
                var celula2 = linha.insertCell(1);   
                var celula3 = linha.insertCell(2); 
                var celula4 = linha.insertCell(3);
                var celula5 = linha.insertCell(4);   
                var celula6 = linha.insertCell(5);
              **  var num1 = celula3.value; **
             **   var num2 = celula4.value; **

                var utilizador = "";
                var preco = "";

                celula1.innerHTML = "a";
                celula2.innerHTML = utilizador; 
                celula3.innerHTML =  preco; 
                celula4.innerHTML =  "1";
               ** celula5.innerHTML =  num1 * num2; **
                celula6.innerHTML =  "+-";
            }
            
  • num1 and num2 are the contents you are inserting into the cells, i.e., price (which I believe to be a variable with some value) and 1. So just this line: cellula5.innerHTML = price * 1; So why recover something you already know who it is? Note: split is with slash and not asterisk

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.