(not a Javascript problem) Help

Armitage

Banned
Feb 23, 2001
8,086
0
0
I came across a cool chunck of javascript to sort tables: http://www.kryogenix.org/code/browser/sorttable/
and I'm trying to incorporate into some of my stuff. But I've never really done anything with Javascript (and am not a big web/html guy to begin with) and it's giving me problems.

I am attempting to include the javascript file with the following statement in the head section of my page:
<script type="text/javascript" src="sorttable.js"></script>

I don't think it's relavent, but the page is generated via a perl script and the line above is generated with the follow9ing print statement:

print '<script type="text/javascript" src="sorttable.js"></script>';

When I load the page, it doesn't work as expected and on checking the server error log I find the following:

[Thu Mar 09 11:31:54 2006] [error] syntax error at /srv/www/cgi-bin/sorttable.js line 5, near ") {"\nBareword found where operator expected at /srv/www/cgi-bin/sorttable.js line 6, near "// Find"\nsyntax error at /srv/www/cgi-bin/sorttable.js line 10, near "tbls["\nBareword found where operator expected at /srv/www/cgi-bin/sorttable.js line 12, near "//initTable"\nsyntax error at /srv/www/cgi-bin/sorttable.js line 12, near "//initTable"\nsyntax error at /srv/www/cgi-bin/sorttable.js line 18, near ") {"\n

Here are the first 30 lines of the sorttable.js file. Any ideas??

FWIW, the server is Apache2 on SuSe
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Ok, here's another lead maybe - I had made the file executable - but that's not right is it? I think that when the server gets the request it is attemptiong to execute it, since its in the cgi-bin directory.

I made the file non-executable which gives me a permissions error, so I think this is true.

I tried putting it in the static html directory (/srv/www/htdocs), but now I'm getting path problems - it can't find the file. How do I tell it where to look? I tried putting in the absolute path, but that doesn't work either.
 

notfred

Lifer
Feb 12, 2001
38,241
4
0
don't put non-executable files in your cgi-bin directory, they will attempt to be executed as CGI programs. Move the js file somewhere *outside* the cgi-bin folder.

You tell it where to look by saying src="/sorttable.js" or src="../sorttable.js" or wherever the file is located that the web browser can find it from. You can do src="http://domain.com/js/sorttable.js" as long as the web browser will know where to look for it.

BTW, this is not a js problem. :p
 

Armitage

Banned
Feb 23, 2001
8,086
0
0
Originally posted by: notfred
don't put non-executable files in your cgi-bin directory, they will attempt to be executed as CGI programs. Move the js file somewhere *outside* the cgi-bin folder.

You tell it where to look by saying src="/sorttable.js" or src="../sorttable.js" or wherever the file is located that the web browser can find it from. You can do src="http://domain.com/js/sorttable.js" as long as the web browser will know where to look for it.

../sorttable.js didn't work, but just /sorttable.js did. Makes sense - that's why it's called DocumentRoot I guess

BTW, this is not a js problem. :p

Yep, it's a bonehead newbie web developer problem :p

Anyway, it's a pretty cool script - include the script and add two parameters to your <table> tag and your table is sortable! I have to hack some things a bit in the column type detection and comparison functions a bit, but it should be pretty easy.

 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: Armitage
../sorttable.js didn't work ...
That's because it depends on where your perl script is being accessed from. What's the url you see in the browser when displaying the page with the table? The ../ stuff works just like a unix file system so it should be dead obvious how to navigate around to where you've got it accessible.