Insert Line Break After Each Tr Tag Row

How to put line break between th and td?

You are creating a table and nothing can be put outside the table cells. If you want to have the forms element under the headers, just create one row with headers and one row with forms elements:

<table>
<tr>
<th>Your Email</th>
<th>Job Category</th>
</tr>
<tr>
<td>
<input type="text" name="userEmail" value="" id="userEmail" required="">
</td>
<td>
<label><input type="radio" name="rd1" value="Programmer" id="rd1">Programmer</label><br>
<label><input type="radio" name="rd2" value="Web Developer" id="rd2">Web Developer</label><br>
</td>
<tr>
</table>

How can I add a line break to each row in my returned table?

There are some incorrect parsing and string manipulation happening in this code but it's a pretty easy fix:

const Nightmare = require('nightmare')
const nightmare = Nightmare({ show: true })
const fs = require('fs');


nightmare
.goto('https://www.google.com')
.type('#lst-ib', 'datatables')
.click('input[value= "Google Search"]')
.click('.rc >.r > a')
.select('select[name="example_length"]', "100")

.evaluate(function () {
const headerFields = document.querySelectorAll("#example thead tr th")
const peopleList = document.querySelectorAll("#example tbody tr")

const people = Array
.from(peopleList)
.map(entry => entry
.innerText
.replace(/\t/g, ',')
)
const header = Array
.from(headerFields)
.map(headerEntry => headerEntry
.innerText
)
.join(',')

return ([])
.concat(header, people)
.join('\n')
})

.end()

.then(result => fs.writeFile(
'./testfile.csv',
result,
'utf8',
function (err) {
if (err) throw err;
console.log('your file is saved')
}
)
)
.catch((err) => {
console.error(err)
});

First we change the error handler to a more realistic example that will throw us to the same .catch statement every time and can accept a debugger break.

Next we change the write file to write the raw string so it will actually output a CSV, not a JSON string(which will cause everything to be on the same line)

Finally we change the evaluate callback to transform the nodeList(s) to Array, transform then, and eventually join them all with newlines.

The only issue you might run into is a timing issue so some wait statements might be exactly what you want.

Line breaks in html table

You can do this by setting a width for the table and you could also use

word-wrap:break-word;

In order to prevent really long words to break out of boundaries.

Width is best set in css:

Edit: include

table-layout:fixed;

Demo

http://jsbin.com/atonut/1/edit

table {
width:500px;
table-layout:fixed;
}


td {
word-wrap:break-word;
}

If your problem is a lot of text rather then incredibly long words, only use width, and leave the word-wrap out. Hope that helps.

break row from specific td to next line

Well thanks to Hidden Hobbes after his answer i found a way to do it.

May be its not that prominent code but yes its working absolutely fine.

Using display:block in <tr> and float:left in .break

tr {  display: block}td.break {  float: left;  line-height: 22px;}
<table>  <tr>    <td>hdv</td>    <td>hdv</td>    <td class="break">hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td class="break">hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>    <td>hdv</td>  </tr></table>

Add line break between data in TD

Change:

<td>' . $result['garment_type'] . '</td>

to

<td>' . str_replace(' ', '<br />', $result['garment_type'] ) . '</td>

This will generate the following HTML:

<td>gildan<br>white<br>4s<br><br>basic<br>red<br>10m</td>

Applying page-break-before to a table row (tr)

Inside <head>, set this style in your CSS stylesheet

<head>
<style>
@media print {
tr.page-break { display: block; page-break-before: always; }
}
</style>
</head>

That way, it will produce a page break during printing right before this table row.

<tr class="page-break">
</tr>


Related Topics



Leave a reply



Submit