Add External jscript to html document |
Add External jscript to html document |
jrd |
Aug 15 2020, 12:01 PM
Post
#1
|
Group: Members Posts: 2 Joined: 15-August 20 Member No.: 27,495 |
I'm working on an html table in which I want to add search functionality and title row freezing (row 1 always visible).
The document I'm working on uses this to build the html table, the data is generated by a query which is run previously. CODE quote = chr(34) crlf = chr(13) & chr(10) fnArrToHtmlError = "" fnArrToHtmlStatus = true '** validate data array numDataCells = Ubound(fnArrToHtmlDataArray) 'count all cells IF ( ( numDataCells = 0) OR (numDataHeaderCells = 0) ) THEN fnArrToHtmlError = "dataArray empty" fnArrToHtmlStatus = false RETURN ENDIF status = clearArray("tempArray") status = ArraySubset(fnArrToHtmlDataArray, "tempArray", 1, 1, 1, 99999999) ' get the first row of the array numDataCols = Ubound(tempArray) 'count all cells in the first row (to get array width) '** validate optional data header array numDataHeadersCells = Ubound(fnArrToHtmlDataHeadersArray) 'count all cells numDataHeaderRows = Ubound(fnArrToHtmlDataHeadersArray,1 ) 'count number of columns IF ( ( numDataHeaderRows <> 1) OR (numDataHeaderCells = 0) ) THEN haveHeaders = false 'must have same number of cols as data array ELSE haveHeaders = true ENDIF '** if showing headers check number of cols in header and data match IF ( ( haveHeaders) AND ( Len(numDataHeadersCells) <> Len(numDataCols)) )THEN fnArrToHtmlError = "data and headers have different number of columns" fnArrToHtmlStatus = false RETURN ENDIF '** validate title IF (fnArrToHtmlTitle = "fnarrtohtmltitle" ) THEN fnArrToHtmlTitle = "" ENDIF IF (fnArrToHtmlTitle <> "" ) THEN haveTitle = TRUE ELSE haveTitle = FALSE ENDIF ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- htmlString = "" '** add optional title IF (haveTitle) THEN htmlString = htmlString & "<b>" & fnArrToHtmlTitle & "</b>" htmlString = htmlString & "<br><br>" ENDIF '** add table format htmlString = htmlString & "<table border=" & quote & "1" & quote & " cellspacing =" & quote & "0" & quote & " cellpadding =" & quote & "5" & quote & ">" '** add optional table headers IF (haveHeaders) THEN htmlString = htmlString & "<tr>" FOR col = 1 to Ubound(fnArrToHtmlDataHeadersArray) thisHeader = fnArrToHtmlDataHeadersArray[1, col] htmlString = htmlString & "<th>" & thisHeader & "</th>" NEXT 'col htmlString = htmlString & "</tr>" ENDIF [color=#FF6666]'Add js source information THIS IS NOT WORKING[/color] htmlString = htmlString & "<script src=""../jquery.fixedheadertable.js""></script>" 'htmlString = htmlString & <script src="js/arr2html_js/jquery.fixedheadertable.min.js"></script> 'htmlString = htmlString & <script src="js/arr2html_js/jquery.mousewheel.js"></script> '** create table of data IF (Ubound(fnArrToHtmlDataArray) = 1) THEN dataHtmlString = ArrayToCSVString(fnArrToHtmlDataArray, "</td></tr><tr><td>") 'seperate cells with end cell/row, start row/cell" dataHtmlString = stringReplace(dataHtmlString,"<td></td>", "</td> <td>") 'fix empty cells (replace with non breaking space) dataHtmlString = "<tr><td>" & dataHtmlString & "</td></tr>" ' add table/data start and data/table end ELSE dataHtmlString = ArrayToCSVString(fnArrToHtmlDataArray, "</td><td>") 'seperate cells with "end cell/start cell" dataHtmlString = stringReplace(dataHtmlString, crlf, "</td></tr><tr><td>") 'add "end cell/row, start row/cell" to end each line dataHtmlString = stringReplace(dataHtmlString,"<td></td>", "</td> <td>") 'fix empty cells (replace with non breaking space) dataHtmlString = left(dataHtmlString, (len(dataHtmlString) - len("<tr><td>"))) 'remove "start row/cell" added previously from the end) dataHtmlString = "<tr><td>" 'add "start row/cell" to the beginning ENDIF '** add table to html htmlString = htmlString & dataHtmlString--------------------------------------------------------------------------------------------------------------------------------------------------- windowWidth = 1000 windowHeight = 600 buttonLabelsArray[1] = "OK" buttonLabelsArray[2] = "CSV" buttonLabelsArray[3] = "Print" buttonIndex = OpenHtmlDisplayDialog(htmlString, windowWidth, windowHeight, buttonLabelsArray) I have tried various places and syntax's, but it always throws an error when it hits the js source information line. The js is located here: E:\LABWARE_DEV\SERVER\COMMON\VISUALWORKFLOWS\js\ Where should I add the source and how should I format the line? Thanks, Jeff |
Christian J |
Aug 15 2020, 12:59 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,630 Joined: 10-August 06 Member No.: 7 |
and title row freezing (row 1 always visible). That usually requires complicated solutions, alas. QUOTE CODE htmlString = htmlString & "<script src=""../jquery.fixedheadertable.js""></script>" I'm not familiar with the above language, but at least in PHP you'd have to escape doublequote characters that are part of the output, something like this: CODE htmlString = htmlString & "<script src=\"../jquery.fixedheadertable.js\"></script>" QUOTE CODE 'htmlString = htmlString & <script src="js/arr2html_js/jquery.fixedheadertable.min.js"></script> 'htmlString = htmlString & <script src="js/arr2html_js/jquery.mousewheel.js"></script> Those two seem to have missing ending single quotes. QUOTE The js is located here: E:\LABWARE_DEV\SERVER\COMMON\VISUALWORKFLOWS\js\ That looks like your local disk. The JS file needs to be uploaded to the server, so that browsers can load it along with the HTML file. (And even if you just want to open HTML files from your own local file system, your browsers may not allow javascript to run locally by default.) |
CharlesEF |
Aug 15 2020, 02:06 PM
Post
#3
|
Programming Fanatic Group: Members Posts: 1,981 Joined: 27-April 13 From: Edinburg, Texas Member No.: 19,088 |
If you want the header row (row 1) to always be visible then use the '< thead >' tag. Along with '< tfoot >' the browser should show them on every page. (Remove spaces)
|
jrd |
Aug 15 2020, 02:23 PM
Post
#4
|
Group: Members Posts: 2 Joined: 15-August 20 Member No.: 27,495 |
The jscript files are on a server, it's just noted as E drive. The language I'm using is lims basic, it will accept html and jscript but not php. The two with missing single quotes are commented out.
For purposes of this issue, just assume I'm only dealing with htmland javascript. Also, this is not being displayed in a web browser, just the labware application which is written in smalltalk. Not sure if that helps clarify or not? |
Lo-Fi Version | Time is now: 28th March 2024 - 06:56 AM |