Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Coding style TD工作于居中和左对齐,但不工作于右对齐_Coding Style_Alignment_Html Table_Dynamic Html - Fatal编程技术网

Coding style TD工作于居中和左对齐,但不工作于右对齐

Coding style TD工作于居中和左对齐,但不工作于右对齐,coding-style,alignment,html-table,dynamic-html,Coding Style,Alignment,Html Table,Dynamic Html,我的代码每天添加一行表。第一行的对齐是静态的,但其他行的对齐不是静态的。除此之外,我还测试了带有“中心对齐”属性的dinamic内容,效果良好 下面是我引用的部分代码,在完整函数的下面 colsfila=document.createElement('td'); textonodo=document.createTextNode(qTrib); idnodo='qTrib'+NUM_FILAS; colsfila.setAttribute('id', idnodo); colsfila.setA

我的代码每天添加一行表。第一行的对齐是静态的,但其他行的对齐不是静态的。除此之外,我还测试了带有“中心对齐”属性的dinamic内容,效果良好

下面是我引用的部分代码,在完整函数的下面

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();
}
colsfila=document.createElement('td');
textonodo=document.createTextNode(qTrib);
idnodo='qTrib'+NUM_FILAS;
colsfila.setAttribute('id',idnodo);
setAttribute('onclick','addInputdetCompra(this)');
setAttribute('style','text align:center;');
colsfila.appendChild(textonodo);
诺瓦菲拉·阿佩奇尔德(科尔斯菲拉);
colsfila=document.createElement('td');
textonodo=document.createTextNode(vUnTrib);
idnodo='vUnTrib'+NUM_FILAS;
var align='rigth';
colsfila.setAttribute('id',idnodo);
setAttribute('onclick','addInputdetCompra(this)');
colsfila.appendChild(textonodo);
setAttribute('style','text-align:rigth;');
诺瓦菲拉·阿佩奇尔德(科尔斯菲拉);
函数importxmlcompra(){
var novostring=新字符串(document.getElementById('file').value);
如果(字符串!=''){
oPed.open(“GET”、novostring、false);
oPed.send();
var结果=oPed.responseXML;
if(!result.documentElement&&oPed.responseStream){
结果.负载(oPed.responseStream);
}   
}否则{
警报(“有利于seleccione un arquivo XML”);
}
如果(!result | | result.getElementsByTagName('emit')。长度==0){
返回};
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]。子节点[0]。节点值;
document.getElementById('cnpj')。value=cnpj;
var razaosocialimportada=emit.getElementsByTagName(“xNome”)[0]。子节点[0]。节点值;
document.getElementById(“xNome”).value=razaosocialimportada;
var ide=result.getElementsByTagName(“ide”)[0];
var nNF=ide.getElementsByTagName(“nNF”)[0]。子节点[0]。节点值;
document.getElementById(“nNF”).value=nNF;
var vNF='R$'+number_格式(result.getElementsByTagName(“vNF”)[0].childNodes[0].nodeValue,2',',',';
document.getElementById(“vNF”).value=vNF;
var detlength=result.getElementsByTagName(“det”).length;
变量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;
而(jTypo:

如果你弹出浏览器的错误控制台(例如Firefox中的shift-ctrl-J),你会看到一个错误闪过。

你在多个地方拼写错误。搜索并替换
right
right

colsfila.setAttribute('style','text-align :rigth;');
                                           ^^^^^ - should be 'right'