469,362 Members | 2,317 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,362 developers. It's quick & easy.

Passing text to a new window

Hi whats the easiest way to pass text from one page to another.

I have a form on one page that has a textbox and "go" button.
when the user selects Go, i would like it to go to another window
with the text he/she already inputed filled in the textbox.

Aug 7 '06 #1
4 1192
Br**************@gmail.com wrote:
Hi whats the easiest way to pass text from one page to another.

I have a form on one page that has a textbox and "go" button.
when the user selects Go, i would like it to go to another window
with the text he/she already inputed filled in the textbox.
Try it for another page in your own domain first, then it will be easy
to see that you can't do it for someone else's site.

Aug 7 '06 #2
Br**************@gmail.com wrote:
Hi whats the easiest way to pass text from one page to another.

I have a form on one page that has a textbox and "go" button.
when the user selects Go, i would like it to go to another window
with the text he/she already inputed filled in the textbox.
Hi,

The easiest way is to use a serverside language, like PHP.
If that is no option, just pass the text to the next page using the URL.

From your first page:
<form action="nextpage.html" METHOD="GET">
<input type="text" name="yourname">
<input type="button" value="go">
</form>

If somebody filled in "Joe Jackson", the URL will contain:
nextpage.html?yourname=Joe%20Jackson

From nextpage.html
<script type="text/javascript">
// get the passed value for yourname
var query = location.search.substring(1);
// query now contains yourname=Joe%20Jackson
// now do basic stringmanipulation to retrieve the actual name.

</script>
Regards,
Erwin Moller
Aug 7 '06 #3
Thanks Erwin,
thats great. thanks i thought that was the simplest.

do you know an even simpler way.
can you do it simple like this line
javascript:void(document.body.style.backgroundColo r='#c00')
Hi,

The easiest way is to use a serverside language, like PHP.
If that is no option, just pass the text to the next page using the URL.

From your first page:
<form action="nextpage.html" METHOD="GET">
<input type="text" name="yourname">
<input type="button" value="go">
</form>

If somebody filled in "Joe Jackson", the URL will contain:
nextpage.html?yourname=Joe%20Jackson

From nextpage.html
<script type="text/javascript">
// get the passed value for yourname
var query = location.search.substring(1);
// query now contains yourname=Joe%20Jackson
// now do basic stringmanipulation to retrieve the actual name.

</script>
Regards,
Erwin Moller
Aug 7 '06 #4
Br**************@gmail.com wrote:
Thanks Erwin,
thats great. thanks i thought that was the simplest.

do you know an even simpler way.
can you do it simple like this line
javascript:void(document.body.style.backgroundColo r='#c00')
Well yes.
If you have already 2 windows, you can use Javascript to communicate
directly (assuming the 2 windows are in the same domain).

eg from mainpage:
var myNewWindowRef = window.open(..etc..);

// call a function in new window:
myNewWindowRef.document.setName("John");

The last call tries to pass the string "John" directly to a function named
setName in the new window.
(Pay attention however that the second window must be fully loaded first
before the Javascriptfunctions become available, otherwise you'll get an
error of course because the function doesn't exist.)

Regards,
Erwin Moller

>
>Hi,

The easiest way is to use a serverside language, like PHP.
If that is no option, just pass the text to the next page using the URL.

From your first page:
<form action="nextpage.html" METHOD="GET">
<input type="text" name="yourname">
<input type="button" value="go">
</form>

If somebody filled in "Joe Jackson", the URL will contain:
nextpage.html?yourname=Joe%20Jackson

From nextpage.html
<script type="text/javascript">
// get the passed value for yourname
var query = location.search.substring(1);
// query now contains yourname=Joe%20Jackson
// now do basic stringmanipulation to retrieve the actual name.

</script>
Regards,
Erwin Moller
Aug 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Wade Wegner | last post: by
2 posts views Thread by Les Peabody | last post: by
3 posts views Thread by Aaron | last post: by
5 posts views Thread by Steve | last post: by
2 posts views Thread by Geoff Cox | last post: by
6 posts views Thread by vncntj | last post: by
reply views Thread by Adrienne Boswell | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.