in reply to Talk with Javascript

Should be pretty simple,

All you need to do is print

<script language=javascript> <!--// var myaarray = new Array("item0","item1"); var myarray[0] = "f00f00f0"; function myClientSideSortFunction(foo) { //sortstuffnow //output result of sort to form field } //--> </script>
with the rest of your generated file

I suggest you use arrays, because forms can be changed by a user, unless you make them read only with javascript, or hidden.

Another reason to use arrays, it takes less characters than form fields, plus less code.

 

What kind of sort do you want to do?

for javascript help see http://www.webreference.com/js/

 

"cRaZy is co01, but sometimes cRaZy is cRaZy".
                                                      - crazyinsomniac

Replies are listed 'Best First'.
RE: Re: Talk with Javascript
by Anonymous Monk on Sep 09, 2000 at 23:07 UTC
    Thanks for the help! But is it possible to do something like this: print "Content-type: text/html\n\n"; print "<html><head><title>Matches</title>\n"; print "<SCRIPT src=../sort.js>\n"; print "</script></head>\n"; print "<body onload=init(this.form)>\n"; In other words, can CGI send back a HTML page that includes a javascript source file? I don't want to display the javascript functions and variables directly in the CGI program. Thanks, Molly
      That's easy to do. Just open up your JavaScript source file, and do a nice tight loop like so:
      open (INPUT, $filename) or warn "Can't open $filename: $!"; print while (<INPUT>); close INPUT;
      You'll have to put that after the headers and in the appropriate spot of your HTML, but it's not tricky.

      I think you can also refer to an external JavaScript source file within the HTML, but maybe I'm confusing it with CSS. That's probably even easier.

      Somehow my sample code is not displayed correctly. Here is it again: print "Content-type: text/html\n\n"; print "<html><head><title>Matches</title>\n"; print "<script src=../sort.js>"; print "</script></head>\n"; print "<body onload=init(this.form)>\n"; In other words, can CGI send back a HTML page that includes a javascript source file? I don't want to display the javascript functions and variables directly in the CGI program. Thanks, Molly