Código aspx:
Ver original
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Ajax.aspx.vb" Inherits="AJAX1.Ajax" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" /> <div class="header"> <div class="title"> <h1> AJAX </h1> </div> </div> </div> <title>AJAX</title> </head> <body> <form id="form1" runat="server"> <div class="page"> <div id="busqueda"> <asp:Table ID="TableBuscar" runat="server" BorderColor="Gray" CellPadding="2" CellSpacing="5" Width="300px" align="center"> <asp:TableRow Font-Bold="True" Font-Overline="False"> <asp:TableCell ID="TableCellBuscar1" HorizontalAlign="Left" Enabled="True" Width="300px"> <asp:Label ID="LabelBuscar1" runat="server" Text="Introduzca el nombre del operario:" aling="center"></asp:Label><br /> </asp:TableCell> </asp:TableRow> <asp:TableRow> <asp:TableCell ID="TableCellBuscar2" HorizontalAlign="Left" Enabled="True" Width="250px"> <asp:TextBox ID="TextNombreBuscar" runat="server" aling="Left" Width="250px"></asp:TextBox> <asp:Label ID="LabelAsterisco1" runat="server" aling="center"></asp:Label><br /> </asp:TableCell> <asp:TableCell ID="TableCellBuscar3" HorizontalAlign="Left" Enabled="True" Width="50px"> <input id="btnBuscar" type="button" value="BUSCAR" onclick="Ajax.obtener_operarios(getElementById('TextNombreBuscar').value,obtener_operarios_CallBack)" /><br> </asp:TableCell> </asp:TableRow> </asp:Table> </div> <div id="tabla2"> <asp:Table ID="Table2" runat="server" BorderColor="Black" CellPadding="2" CellSpacing="5" Width="770px" align="center" HorizontalAlign="Center"> <asp:TableRow Font-Bold="True" Font-Overline="False" BackColor="Silver"> <asp:TableCell ID="Table2Cell1" HorizontalAlign="Center" Enabled="True" Width="150px" VerticalAlign="Middle"> <asp:Label ID="LabelCell1" runat="server" Text="NºOPERARIO" Font-Bold="True" Font-Underline="True" ForeColor="Black" Font-Size="Medium"></asp:Label> </asp:TableCell> <asp:TableCell ID="Table2Cell2" HorizontalAlign="Center" Enabled="True" Width="300px" VerticalAlign="Middle"> <asp:Label ID="LabelCell2" runat="server" Text="OPERARIO" Font-Bold="True" Font-Underline="True" ForeColor="Black" Font-Size="Medium"></asp:Label> </asp:TableCell> <asp:TableCell ID="Table2Cell3" HorizontalAlign="Center" Enabled="True" Width="170px" VerticalAlign="Middle"> <asp:Label ID="LabelCell3" runat="server" Text="DETALLE MENSUAL" Font-Bold="True" Font-Underline="True" ForeColor="Black" Font-Size="Medium"></asp:Label> </asp:TableCell> <asp:TableCell ID="Table2Cell4" HorizontalAlign="Center" Enabled="True" Width="150px" VerticalAlign="Middle"> <asp:Label ID="LabelCell4" runat="server" Text="MES" Font-Bold="True" Font-Underline="True" ForeColor="Black" Font-Size="Medium"></asp:Label> </asp:TableCell> </asp:TableRow> </asp:Table> </div> <div id="resultado"> </div> </div> </form> <script type="text/javascript"> function obtener_operarios_CallBack(response) { if (response.error != null) { alert("Se presentó un error "); return; } var juntos = response.value.split(";"); miTabla = document.getElementById('Table2') tbBody = document.createElement("tbody"); for (i = 1; i < juntos.length; i++) { var operarios = juntos[i]; var separaroperario = operarios.split("-"); var resultado = i % 2; tr = document.createElement("tr"); tc1 = document.createElement("td"); tc2 = document.createElement("td"); tc3 = document.createElement("td"); tc4 = document.createElement("td"); // tc1.setAttribute("Width", "150px"); // tc1.setAttribute("HorizontalAlign", "Center"); // tc1.setAttribute("VerticalAlign", "Middle"); // tc2.setAttribute("Width", "300px"); // tc2.setAttribute("HorizontalAlign", "Left"); // tc2.setAttribute("VerticalAlign", "Middle"); // tc3.setAttribute("Width", "170px"); // tc3.setAttribute("HorizontalAlign", "Center"); // tc3.setAttribute("VerticalAlign", "Middle"); // tc4.setAttribute("Width", "150px"); // tc4.setAttribute("HorizontalAlign", "Center"); // tc4.setAttribute("VerticalAlign", "Middle"); // tc4.setAttribute("ForeColor", "Red"); tc1.innerHTML = separaroperario[0]; tc2.innerHTML = separaroperario[1]; tc3.innerHTML = separaroperario[2]; tc4.innerHTML = separaroperario[3]; if (resultado == 0) { alert("ENTRA"); // tc1.setAttribute = ("BackColor", "Drawing.Color.AliceBlue"); // tc2.setAttribute = ("BackColor", "Drawing.Color.AliceBlue"); // tc3.setAttribute = ("BackColor", "Drawing.Color.AliceBlue"); // tc4.setAttribute = ("BackColor", "Drawing.Color.AliceBlue"); } tr.appendChild(tc1); tr.appendChild(tc2); tr.appendChild(tc3); tr.appendChild(tc4); tbBody.appendChild(tr); } miTabla.appendChild(tbBody); miCapa = document.getElementById('tabla2'); miCapa.appendChild(miTabla); } </script> </body> </html>
Lo que quiero hacer es darle posición a las celdas desde java script. Había comenzado haciendo lo que se ve comentado dentro del código pero aunque ponga eso no hace caso de las instrucciones que le digo.
alguien me puede echar una mano?
![En dos](http://static.forosdelweb.com/fdwtheme/images/smilies/partido.png)