[Javascript] Inherit data

Peter Brunone peter at brunone.com
Fri May 17 14:35:54 CDT 2002


Glenn,

	First off, I should mention that this is easier with a server-side language
to populate the boxes.  That said, here's what you can do with client-side
Javascript.

	By the way, you should always enclose your form elements in a form as shown
here.

<FORM NAME="mainForm">
<Input type = "text" name="LName" ><br>
<Input type = "text" name="FName" ><br>
</FORM>

	Before you open Page 2, build a URL that includes the LName and FName
parameters, like this (watch for wrapping):

var myURL = "Page2.html?LName=" + document.mainForm.LName.value + "&FName="
+ document.mainForm.FName.value;

	Then you just feed this variable to the window.open function.  On the other
side, you'll have to parse the URL, either with window.location.href or a
more sophisticated function for getting querystring variables (somebody else
on the list probably has just the thing).

	Alternatively you could set cookies and pick them up on the next page...
but that's for another email.

Cheers,

Peter

|-----Original Message-----
|From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
|Behalf Of Glenn Morris
|
|Hello, I am new to Javascript (and this group). What I am trying to do
|is as follows:
|Page1.html - has 2 fields, LName and FName they are input type text.
|What I am trying to do is when a person submits their name a new
|document (Page2.html)
|comes up with both the LName field and the FName field inherited from
|Page1. The thing is I want both those fields to
|be editable (input type="text") on the new form so a person could
|change them. (There will be other fields on the new form but they will
|not
|inherit so there is no problem with them).
|
|Some script I was working on below:
|
|Page1.html
|<Input type = "text" name="LName" ><br>
|<Input type = "text" name="FName" ><br>
|<SCRIPT LANGUAGE="Javascript">
|var newWindow
|function NextPage()
|{
|newWindow = window.open
|("Page2.html")
|}
|{
|newWindow.opener = self
|}
|</SCRIPT>
|<INPUT TYPE=button VALUE="Enter" onClick="NextPage()">
|
|Page2.html
|<Input type = "text" name="LName" ><br>
|<Input type = "text" name="FName" ><br>
|




More information about the Javascript mailing list