Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5978741
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:33:37+00:00 2026-05-22T21:33:37+00:00

My code add one row of a table dinamicaly. The alignment wrks for the

  • 0

My code add one row of a table dinamicaly. The alignment wrks for the firs row that is static but not for the other rows. Intead of this I have tested the dinamic content with center align attribute and it works.

Here is the part of the code that I am refering, and below the complete function.

colsfila=document.createElement('td');
textonodo=document.createTextNode(qTrib);
idnodo='qTrib'+NUM_FILAS;
colsfila.setAttribute('id', idnodo);
colsfila.setAttribute('onclick','addInputdetCompra(this)');
colsfila.setAttribute('style', 'text-align: center;');
colsfila.appendChild(textonodo);
novafila.appendChild(colsfila);

colsfila=document.createElement('td');
textonodo=document.createTextNode(vUnTrib);
idnodo='vUnTrib'+NUM_FILAS;
var align='rigth';
colsfila.setAttribute('id', idnodo);
colsfila.setAttribute('onclick','addInputdetCompra(this)');
colsfila.appendChild(textonodo);
colsfila.setAttribute('style','text-align :rigth;');
novafila.appendChild(colsfila);

function importxmlcompra(){
    var novostring= new String(document.getElementById('file').value);

    if (novostring!=''){
        oPed.open("GET",novostring, false);
        oPed.send();
        var result = oPed.responseXML;
        if (!result.documentElement && oPed.responseStream) {
        result.load(oPed.responseStream);
        }   
    }else{
            alert ("Por favor seleccione un arquivo XML");
    }
    if (!result||result.getElementsByTagName('emit').length==0){
        return};
    var emit=result.getElementsByTagName("emit")[0];
    var dEmi=result.getElementsByTagName('dEmi')[0].childNodes[0].nodeValue;
    dEmi=dataNF(dEmi);
    document.getElementById('dEmi').value=dEmi;
    var CNPJ=emit.getElementsByTagName('CNPJ')[0].childNodes[0].nodeValue;
    document.getElementById('cnpj').value=CNPJ;
    var razaosocialimportada=emit.getElementsByTagName("xNome")[0].childNodes[0].nodeValue;
    document.getElementById("xNome").value=razaosocialimportada;
    var ide=result.getElementsByTagName("ide")[0];
    var nNF=ide.getElementsByTagName("nNF")[0].childNodes[0].nodeValue;
    document.getElementById("nNF").value=nNF;
    var vNF='R$'+number_format(result.getElementsByTagName("vNF")[0].childNodes[0].nodeValue,2,',','.');
    document.getElementById("vNF").value=vNF;

    var detlength=result.getElementsByTagName("det").length;
    var j=0, cProd, xProd, vUnTrib, qTrib, vProd;
    var tabledet=document.getElementsByTagName('table')[0];
    var tablerows=document.getElementsByTagName('table')[0].rows.length;
    var novafila, colsfila, idnodo, textonodo, imgnodo, attid, ant;

    while(j<detlength){
        det=result.getElementsByTagName('det')[j];
        cProd=det.getElementsByTagName('cProd')[0].childNodes[0].nodeValue;
        xProd=det.getElementsByTagName('xProd')[0].childNodes[0].nodeValue;
        vUnTrib=number_format(det.getElementsByTagName('vUnTrib')[0].childNodes[0].nodeValue,2,',','.');
        qTrib=number_format(det.getElementsByTagName('qTrib')[0].childNodes[0].nodeValue,0,'','.');
        vProd=number_format(det.getElementsByTagName('vProd')[0].childNodes[0].nodeValue,2,',','.');


        if(validacProd(cProd)==true){

            if (tablerows==2&& document.getElementById('cProd0').innerHTML=='0'){
              document.getElementById('cProd0').innerHTML=cProd;
              document.getElementById('xProd0').innerHTML=xProd;
              document.getElementById('vUnTrib0').innerHTML=vUnTrib;
              document.getElementById('qTrib0').innerHTML=qTrib;
              document.getElementById('vProd0').innerHTML=vProd;
            }else{
                novafila=document.createElement('tr');
                textonodo=document.createTextNode(cProd);
                attid=document.createAttribute('id');
                colsfila=document.createElement('td');
                idnodo='cProd'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('onclick','addInputdetCompra(this)');
                colsfila.appendChild(textonodo);
                novafila.appendChild(colsfila);
                tabledet.appendChild(novafila)

                colsfila=document.createElement('td');
                textonodo=document.createTextNode(xProd);
                idnodo='xProd'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('onclick','addInputdetCompra(this)');
                colsfila.appendChild(textonodo);
                novafila.appendChild(colsfila);

                colsfila=document.createElement('td');
                idnodo='codproduto'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('style','display:none');
                novafila.appendChild(colsfila);

                colsfila=document.createElement('td');
                idnodo='descproduto'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('onclick','addInputdetCompra(this)');
                novafila.appendChild(colsfila);

                colsfila=document.createElement('td');
                textonodo=document.createTextNode(qTrib);
                idnodo='qTrib'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('onclick','addInputdetCompra(this)');
                colsfila.setAttribute('style', 'text-align: center;');
                colsfila.appendChild(textonodo);
                novafila.appendChild(colsfila);

                colsfila=document.createElement('td');
                textonodo=document.createTextNode(vUnTrib);
                idnodo='vUnTrib'+NUM_FILAS;
                var align='rigth';
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('onclick','addInputdetCompra(this)');
                colsfila.appendChild(textonodo);
                colsfila.setAttribute('style','text-align :rigth;');
                novafila.appendChild(colsfila);

                colsfila=document.createElement('td');
                textonodo=document.createTextNode(vProd);
                idnodo='vProd'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('align', 'rigth');
                colsfila.appendChild(textonodo);
                novafila.appendChild(colsfila);

                colsfila=document.createElement('td');
                imgnodo=document.createElement('img');
                idnodo='addrow'+NUM_FILAS;
                colsfila.setAttribute('id', idnodo);
                colsfila.setAttribute('onclick','addRowdetCompra(this)');
                imgnodo.setAttribute('src','../../../imagens/addrow/addrow.png');
                colsfila.appendChild(imgnodo);
                novafila.appendChild(colsfila);
                document.getElementsByTagName('table')[0].appendChild(novafila);
            }
        }
        tablerows=document.getElementsByTagName('table')[0].rows.length;
        NUM_FILAS++;
        j++;
    }
    comandosfilas();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:33:38+00:00Added an answer on May 22, 2026 at 9:33 pm

    You’re spelling right incorrectly in multiple places. Do a search and replace for rigth to right.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written some code to add a table row which you can see below.
i have a very simple table with only one row that has a uiswitch
In my table I have many rows with data. One row has seven columns
I'm using this code: Dim cListItems As New System.Collections.Generic.List(Of Combobox_values) cListItems.Add(New Combobox_values(One, 1)) cListItems.Add(New
I add code in .cs public static readonly DependencyProperty lbStatusProperty = DependencyProperty.Register(lbStatus, typeof(string), typeof(SingleTalkView),
I have code to add item to cache: public static void AddTask(string name, string
I'm trying to add rows dynamically to a System.Web.UI.WebControls.Table control in ASP.NET. I found
I have a table which has no primary key and I can't add one
I'm looking for a way to expand/collapse all table rows at one click. Here
I have a table that is dynamically created in some c# code-behind when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.