2012-08-04 63 views
0

我有具有搜索表单的索引文件。搜索的结果是一张表格。我在index.php中的原始表使用数据表,风格和功能都很完美。这里要说的是显示了searchDate.php文件的结果采取的结果我的index.php文件的一部分: 来源: 要: 阿贾克斯输出没有风格

  <select name="dateOption" id="dateOption"> 
       <option value="order"> Order </option> 
       <option value="inventory"> Inventory </option> 
       <option value="po"> PO# </option> 
      </select> 
      <input type="text" name="searchinput" id="searchinput" /> 
      <input type="button" value="SUBMIT" onclick="getDate();" /> 
     </form> 

这里是GETDATE()函数:

function getDate() { 
       $.post('searchDate.php' , { dateKey: $("#searchinput").val(), 
               selected: $("#dateOption").val(), 
               from: $("#date").val(), 
               to: $("#date2").val() 
               }, 
        function(output) { 
         $('#mainTable').empty(); 
         $('#orderSearch').empty(); 
         $('#newOrder').empty(); 
         $(".line").hide(); 
         $("#loadNewInvoice").hide(); 
         $('#searchResult').append(output); 
         $('#searchResult').css('display','block'); 
         $('#searchResult').show("blind"); 

       }); 
      } 

的结果是相同的id和类作为我原来的工作表的一个表格。但是,结果不起作用,没有风格。 预先感谢您。 编辑: 这里是css和我的数据表结构,以防万一:

table.display { 
margin: 0 auto; 
clear: both; 
width: 100%; 


} 

table.display thead th { 
padding: 3px 18px 3px 10px; 
border-bottom: 1px solid black; 
font-weight: bold; 
cursor: pointer; 
* cursor: hand; 

} 

table.display tfoot th { 
padding: 3px 18px 3px 10px; 
border-top: 1px solid black; 
font-weight: bold; 
} 

table.display tr.heading2 td { 
border-bottom: 1px solid #aaa; 
} 

table.display td { 
padding: 3px 10px; 
} 

table.display td.center { 
text-align: center; 
} 

数据表:

$(document).ready(function() { 
var oTable = $('#theTable').dataTable({ 
"bPaginate": true, 
"bScrollCollapse": true, 
"iDisplayLength": 15, 
"oLanguage": { 
     "sSearch": "Search all columns:" 
    }, 
"aoColumnDefs": [ 
    { "asSorting": [ "desc" ], "aTargets": [ 0 ] } 
    ] 

}); 
+0

可以显示的CSS? – 2012-08-04 10:35:18

+0

以及css来自datatables演示文件我只是修改了一下。它与我在页面中的原始表格相同,因此我确信这些样式必须工作,因为两个表格都是相同的,但搜索的结果显然与原始表格不同。 – theWebLover 2012-08-04 10:44:14

+0

如果在桌面上应用css样式,请参阅firebug? – 2012-08-04 10:51:11

回答

0

我有些时间前有同样的问题。 Jquery要求你的所有id在页面中是唯一的。如果这个规则不被遵守,它根本不起作用!

所以,如果你改变了表的ID按照预期的代码应工作。

+0

我确实尝试过,但它也没有工作。不过,我明白了。我所要做的就是在我的searchDate.php文件中链接我所有的java脚本文件和css样式。我的印象是,由于我的输出表带有一个id和一个类,页面必须识别它们并应用样式。但显然情况并非如此。 – theWebLover 2012-08-04 11:31:57