Re: Generating a javascript code

by "Rossi Designs" <webmaster(at)rossidesigns.net>

 Date:  Tue, 20 Jun 2000 14:09:08 -0400
 To:  "Krimm,
Nik" <nik.krimm(at)marchFIRST.com>,
<hwg-languages(at)hwg.org>
 References:  SERVER2
  todo: View Thread, Original
Your best bet is to use some server side scripting like PHP or ASP, but
here's a routine to get variables out of the query string with javascript. I
don't know of a way to get post variables.

<script language="javascript">
<!--
// This routine creates a get_vars object and
// stores all variables from query string in it and
// initializes all variables as javascript variables
// copyright (c) 2000  by Jeff Rossi
if (location.search.length != 0) {
var get_vars = new Object();
get_vars.varName = new Array();
get_vars.varValue = new Array();
var q_str = location.search.substring(1);
var temp_var = q_str.split("&");
for (x=0;x<temp_var.length;x++) {
parts = temp_var[x].split("=");
get_vars.varName[x] = parts[0];
if (isNaN(parseFloat(parts[1]))) {
get_vars.varValue[x] = '"' + parts[1] + '"';
} else get_vars.varValue[x] = parts[1];
eval(get_vars.varName[x] + "=" + get_vars.varValue[x]);
}
}
// -->
</script>

The variable in the query string (which is what you get if you use
method="get") would then exist on your page as javascript variables which
you can use.

Rossi Designs
PO Box 1084
Holly Hill, FL 32125-1084
Phone : (904) 226-8979
URL : http://rossidesigns.net
URL : http://datadrivendesign.com
----- Original Message -----
From: Krimm, Nik <nik.krimm(at)marchFIRST.com>
To: <hwg-languages(at)hwg.org>
Sent: Tuesday, June 20, 2000 11:51 AM
Subject: Generating a javascript code


| Hi all:
|
| I am writing an app where I want to
| 1.  get input from a form
| 2.  generate a new page from the users input which...
| 3.  writes javascript code and HTML into the new document
| 4.  show the new document with the code executed
|
|
| I have the code written that generates a new page of javascript, but I
can't
| figure out how to plug this code into a new
| page and get it to load as code (in one sample I've been able to get the
| code to appear as browser text).  I'd prefer to have the second window
only
| exist when it is called (no saved file on the server).
|
| I know that this is a little fuzzy request, but does anyone have any
| examples or samples that I can look at to see how to do this?
|
|
|
| tia
|

HWG: hwg-languages mailing list archives, maintained by Webmasters @ IWA