[Solved] PHP output array as an HTML table

Try something like this: $data = //your array $html = “<table>”; foreach($data as $row) { $html .= “<tr>”; foreach ($row as $cell) { $html .= “<td>” . $cell . “</td>”; } $html .= “</tr>”; } $html .= “</table>”; Your question is extremenly vague so this is a vague answer, but you should get the general … Read more

[Solved] Up and Down rows from table

Just change appendTo() to insertBefore() and insertAfter() $(document).ready(function() { $(“#table1 tbody tr”).click(function() { $(this).toggleClass(‘selected’); }); }); $(document).ready(function() { $(“#table2 tbody tr”).click(function() { $(this).toggleClass(‘selected’); }); }); $(document).ready(function() { $(“.down”).click(function() { $(‘#table1 tr’).each(function() { if ($(this).attr(‘class’) == ‘selected’) { $(this).insertAfter($(this).nextAll(‘:not(.selected)’).eq(0)); } }); }); }); $(document).ready(function() { $(“.up”).click(function() { $(‘#table1 tr’).each(function() { if ($(this).attr(‘class’) == ‘selected’) { $(this).insertBefore($(this).prevAll(‘:not(.selected)’).eq(0)); … Read more

[Solved] td .cssClass – is this a valid construct? [closed]

If you use a preprocessor like sass, you can nest selectors like that. Not with normal css though. With normal css you would need to do tbody tr td .plusIcon { background: url(../img/left-arrow-blue.png) 15px 18px no-repeat; vertical-align: bottom; padding-left: 42px; } tbody tr td .minusIcon { background: url(../img/down-arrow-blue.png) 15px 18px no-repeat; vertical-align: bottom; padding-left: 42px; … Read more

[Solved] How to pass html table cell value to javascript variable?

This code Adds a click (event) listener to every first <td> of every <tr> On click the text is parsed to int (base10), and the number is passed to the handler function (getNumber(val)) The handler function prints the value read from the <td> to the console // “grabbing” each row const rows = document.getElementsByTagName(‘tr’) // … Read more

[Solved] Write a table by column [closed]

HTML tables are standardized to be defined left-to-right, top-to-bottom. Thus, the only way to do what you’re asking is to reinvent the table using a different DOM structure. For example: <div class=”table”> <div class=”column”> <div class=”cell”>Cell1</div> <div class=”cell”>Cell2</div> <div class=”cell”>Cell3</div> <div class=”cell”>Cell4</div> </div> <div class=”column”> <div class=”cell”>Cell5</div> <div class=”cell”>Cell6</div> <div class=”cell”>Cell7</div> <div class=”cell”>Cell8</div> </div> <div … Read more

[Solved] Custom html table [closed]

Here’s a start for you. Change your onclick attributes to use .call(). This just lets you set the value of this in the functions you’re calling to the value of the first argument you pass to .call(). (In this case, the element that received the event.) <input type=”button” name=”Up1″ value=”Up” onclick=”moveUp.call(this);”> Item 1 <input type=”button” … Read more

[Solved] Create dynamically and add to

as i think (and the comments) … you’re new using jquery… so with jquery its very easy… append/appendTo is what you’re looking for … if you want to add TDs more than one table it’s not usefull to use ID attributes. because W3C says that IDs are unique on a page… better use the class … Read more

[Solved] Create a table dynamically using for loop in .html()

You must create td and text nodes within loop. This code creates only 2 td, so only 2 are visible. Example: var table = document.createElement(‘table’); for (var i = 1; i < 4; i++) { var tr = document.createElement(‘tr’); var td1 = document.createElement(‘td’); var td2 = document.createElement(‘td’); var text1 = document.createTextNode(‘Text1’); var text2 = document.createTextNode(‘Text2’); … Read more

[Solved] JavaScript pull data from HTML table cell to input [closed]

const myInput = document.querySelector(‘#myInput’); const cells = document.querySelectorAll(‘#myTable tr td’); cells.forEach(el => el.addEventListener(‘click’, (e) => myInput.value = e.currentTarget.innerText) ); This is assuming html like the following: <input type=”text” id=”myInput” value=”” /> <table id=”myTable”> <tr> <td>1</td> <td>2</td> <td>3</td> </tr> <tr> <td>4</td> <td>5</td> <td>6</td> </tr> </table> Update (Breakdown of what we are doing above): All we are … Read more

[Solved] How do I convert highly formatted textual table data into HTML? [closed]

Something like this should work. Example is a text file called my_data.txt which contains the following which is literally based on your example: \———\————-\————-\ | Username| IP | Connected | \———\————-\————-\ | test | 127.0.0.1 | Yes | | atest | 192.168.2.1 | No | | aaa | 1.2.3.4 | Yes | \———\————-\————-\ Here is … Read more