繁体   English   中英

通过内容,CSS,Javascript或其他方法格式化基于Web的数据的最简单方法是什么?

[英]What's the easiest way to format web-based data by content, CSS, Javascript, or other method?

我目前有这个HTML:

 <html> <head> <title>IN Print ALL</title> <link rel="shortcut icon" href="\\\\MyServer\\Webcaster\\favicon.ico" /> <style type='text/css'> caption { background-color:333BFF; color:white; border-style:solid; border-width:1px; border-color:336699; text-align:center; } table { font-family:Tahoma; border-collapse:collapse; font-size:15pt; width:85%; border-style:solid; border-color:white; border-width:1px; } th { font-size:10pt; color:black; text-align:center; font-weight:bold; } tbody tr:nth-child(odd) { background: #eee; } tr { } td { font-size:10pt; color:black; border-style:solid; border-width:1px; border-color:cccccc; text-align:left; padding:3px; } </style> <meta http-equiv="refresh" content="30" /> </head> <tbody> <table align="center"> <caption> On The Floor Printing IN ALL as of {%Current Date Time%} </caption> <thead> <tr> <th>Cycle Code</th> <th>Product</th> <th>Description</th> <th>Warehouse</th> <th>Production Due Date</th> <th>Status</th> <th>Status Comment</th> <th>Sales Order Number</th> <th>Job Description</th> <th>Ship Expire Date</th> <th>Days Until Due</th> <th>Total Hours</th> <th>Remaining Sch Hrs</th> <th>Sch Hrs</th> <th>Rev Budget Hrs</th> </tr> </thead> <tbody> {BEGIN*REPEAT} <tr> <td>{UDF_CYCLE}</td> <td>{Product}</td> <td>{Description}</td> <td>{WarehouseCode}</td> <td>{ProductionDueDate}</td> <td>{StatusCode}</td> <td>{CurrentStatusComment}</td> <td>{SalesOrderNo}</td> <td>{UDF_JOBDESC}</td> <td>{ShipExpireDate}</td> <td>{daystilldue}</td> <td>{TotalHours}</td> <td>{RemainingScheduledHours}</td> <td>{ScheduledHours}</td> <td>{RevisedBudgetHours}</td> </tr> {END*REPEAT} </tbody> </table> </body> </html> 

它创建一个漂亮的表来显示数据。 我想要的是{daystilldue} <1以红色字体显示的任何记录。 我一直在查看JavaScript IF语句,但无法使其正常工作。 我会很感激任何想法或煽动最好的方法。

进一步考虑之后,您实际上可以对HTML进行一些小的修改-使用数据属性和选择器来寻找正确的东西。 在这种情况下,它将查找值"0"或任何以"-"开头的值,即负数。 在下面的示例中,我将表缩减为仅几列,并添加了几行以显示模板在某些情况下的扩展方式。

我已经把内部跨度在这个td ,如改变color一的td也影响它的边界。

 span[data-daystilldue="0"], /* anything that's 0 */ span[data-daystilldue^="-"] { /* or anything starting with -, ie negative numbers */ color:red; } table { font-family: Tahoma; border-collapse: collapse; font-size: 15pt; width: 85%; border-style: solid; border-color: white; border-width: 1px; } td { font-size: 10pt; color: black; border-style: solid; border-width: 1px; border-color: cccccc; text-align: left; padding: 3px; } 
 <table align="center"> <thead> <tr> <th>Cycle Code</th> <th>Product</th> <th>Days Until Due</th> </tr> </thead> <tbody> {BEGIN*REPEAT} <tr> <td>{UDF_CYCLE}</td> <td>{Product}</td> <td><span data-daystilldue="{daystilldue}">{daystilldue}</span></td> </tr> <tr> <td>{UDF_CYCLE}</td> <td>Example 1</td> <td><span data-daystilldue="1">1</span></td> </tr> <tr> <td>{UDF_CYCLE}</td> <td>Example 2</td> <td><span data-daystilldue="0">0</span></td> </tr> <tr> <td>{UDF_CYCLE}</td> <td>Example 3</td> <td><span data-daystilldue="-1">-1</span></td> </tr> <tr> <td>{UDF_CYCLE}</td> <td>Example 4</td> <td><span data-daystilldue="-20">-20</span></td> </tr> {END*REPEAT} </tbody> </table> 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM