[HTA] Sorting Table

Anything VBScript-related, including Windows Script Host, WMI, ADSI, and more.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
hackoo
Posts: 103
Last visit: Tue Apr 26, 2016 9:02 am

[HTA] Sorting Table

Post by hackoo »

Hello,
I have a JS that allows you to sort the columns in my table (ASC, DESC).
http://www.kryogenix.org/code/browser/s ... rttable.js
It works if I do the classic html, I can sort my columns generated statically.
VBScript Code
Double-click the code block to select all.
<html>
<script type="text/javascript" src="sorttable.js"></script>
 <table class = 'sortable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td> </tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr></table>
 <body>
<span id = "oDivDisplayArea"></span></br>
</body>
</html>
However, if now I want to sort my table generated in vbs it no longer My table is displayed but becomes static, I can not use the arrows that allow you to sort my columns works.
If you have an idea, I'm interested.
VBScript Code
Double-click the code block to select all.
<html>
<script type="text/javascript" src="sorttable.js"></script>
<script language="VBScript">
Sub window_Onload
	oDivDisplayArea.innerHTML = "<table class = 'sortable'><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td> </tr><tr><td>11</td><td>12</td><td>13</td><td>14</td><td>15</td></tr></table>"
End sub	
</script>
<body>
<span id = "oDivDisplayArea"></span></br>
</body>
</html>
Thank you in advance !
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: [HTA] Sorting Table

Post by jvierra »

You have to build the table as an object using createElement.

Sometimes a page refresh will work. Depends on the browser version.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: [HTA] Sorting Table

Post by jvierra »

Try this version in an attached file.
Attachments
SortHighlightSnippet.zip
Unzip into folder and run Employees.hta
(126.86 KiB) Downloaded 664 times
User avatar
hackoo
Posts: 103
Last visit: Tue Apr 26, 2016 9:02 am

Re: [HTA] Sorting Table

Post by hackoo »

Thank you for sharing this helpful code ;)
This topic is 10 years and 3 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked