472,779 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

passing variable - no answer?!

Hello,

I have written before that I can pass a variable from page 1 to page 2
if I call the variable "name".

Stephen Chalmers has written,
'name' is effectively a reserved word as the variable window.name is
created automatically, but is not read-only.
Use more imaginative names for variables.


Does this explain why I can pass the variable from one page to
another?

It does seem to be much simpler that other methods, eg passing the
value with the URL etc.

Does doing this have any negative side effect?
Cheers

Geoff

Sep 29 '05 #1
10 1605
ASM
Geoff Cox a écrit :
Does this explain why I can pass the variable from one page to
another?
nothing best than a try-demo :

file 'page1.htm' :

<html> <title>page 1</title>
<h3>page 1</h3>
<form action="page2.htm" onsubmit="window.name=this.Name.value">
Enter your name : <input type=text name="Name">
<input type=submit value=GO>
</form></html>

file 'page2.htm' :

<html> <title>page 2</title>
<body onload="document.forms[0][0].value = window.name;">
<h3>page 2</h3>
<form>
Your name is : <input type=text name="Name">
</form></body></html>
It does seem to be much simpler that other methods, eg passing the
value with the URL etc.
yes, if you have only one alone value to pass
Does doing this have any negative side effect?


what negative effect ?
--
Stephane Moriaux et son [moins] vieux Mac
Sep 29 '05 #2
On Thu, 29 Sep 2005 11:36:41 +0200, ASM
<st*********************@wanadoo.fr.invalid> wrote:
Geoff Cox a écrit :
Does this explain why I can pass the variable from one page to
another?


nothing best than a try-demo :

file 'page1.htm' :

<html> <title>page 1</title>
<h3>page 1</h3>
<form action="page2.htm" onsubmit="window.name=this.Name.value">
Enter your name : <input type=text name="Name">
<input type=submit value=GO>
</form></html>

file 'page2.htm' :

<html> <title>page 2</title>
<body onload="document.forms[0][0].value = window.name;">
<h3>page 2</h3>
<form>
Your name is : <input type=text name="Name">
</form></body></html>
It does seem to be much simpler that other methods, eg passing the
value with the URL etc.


yes, if you have only one alone value to pass
Does doing this have any negative side effect?


what negative effect ?


Stephane.

Thanks for trying this approach. I haven't seen any mention of this
befofe.

I was wondering whether if this uses "a sort of reserved word" whether
this can cause any problems?

Cheers

Geoff




Sep 29 '05 #3
ASM
Geoff Cox a écrit :
On Thu, 29 Sep 2005 11:36:41 +0200, ASM
<st*********************@wanadoo.fr.invalid> wrote:

Stephane.

Thanks for trying this approach. I haven't seen any mention of this
befofe.

I was wondering whether if this uses "a sort of reserved word" whether
this can cause any problems?


as said by otherwise

'name' is a reserved word for everything in javascript

in this try-demo this reserved word is used for what it was done
that's to say : to give a name to an object

because 'window' is the all first object in javascript
and
because 'window' can be omitted

if your window has a name and you do i.e. alert(name)
that would have to open an alert-box with the name of the window

so, this try-demo can become :

file 'page1.htm' :

<html> <title>page 1</title>
<script type="text/javascript">
function go(aName) { name=aName; }
</script>
<h3>page 1</h3>
<form action="page2.htm">
Enter your name :
<input type=text name="Name" onchange="go(this.value);">
<input type=submit value=GO>
</form></html>

file 'page2.htm' :

<html>
<title>page 2</title>
<body onload="document.forms[0].Name.value = name;">
<h3>page 2</h3>
<form>
Your name is :
<input type=text name="Name">
</body></form></html>
As you can see now, using IE (don't more work with FF),
what was your variable 'name'
was in fact the reserved word 'name'
and, because used alone, was : name of window

This particularism (a window records its name)
is useful with popups

--
Stephane Moriaux et son [moins] vieux Mac
Sep 29 '05 #4
On 29/09/2005 09:46, Geoff Cox wrote:
[Using global 'name'] Does this explain why I can pass the variable
from one page to another?
The property that you are using is a property of the tab or browser
instance, rather than the document, unlike most properties of the global
object.
It does seem to be much simpler that other methods, eg passing the
value with the URL etc.
Parsing values out of the query string (or a cookie) is hardly a
difficult task.
Does doing this have any negative side effect?


Other than the fact that it might not work? There's no particular reason
why it should, and indeed it doesn't in Firefox.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.
Sep 29 '05 #5
On Thu, 29 Sep 2005 16:15:55 GMT, Michael Winter
<m.******@blueyonder.co.uk> wrote:
Does doing this have any negative side effect?
Other than the fact that it might not work? There's no particular reason
why it should, and indeed it doesn't in Firefox.


Michael,

OK - that is a negative effect.

Thanks

Geoff



Mike


Sep 29 '05 #6
On Thu, 29 Sep 2005 17:22:52 +0200, ASM
<st*********************@wanadoo.fr.invalid> wrote:
so, this try-demo can become :

file 'page1.htm' :

<html> <title>page 1</title>
<script type="text/javascript">
function go(aName) { name=aName; }
</script>
<h3>page 1</h3>
<form action="page2.htm">
Enter your name :
<input type=text name="Name" onchange="go(this.value);">
<input type=submit value=GO>
</form></html>

file 'page2.htm' :

<html>
<title>page 2</title>
<body onload="document.forms[0].Name.value = name;">
<h3>page 2</h3>
<form>
Your name is :
<input type=text name="Name">
</body></form></html>
As you can see now, using IE (don't more work with FF),
what was your variable 'name'
was in fact the reserved word 'name'
and, because used alone, was : name of window

This particularism (a window records its name)
is useful with popups

Thanks Stephane.

Food for thought!

Cheers

Geoff
Sep 29 '05 #7
> It does seem to be much simpler that other methods, eg passing the
value with the URL etc.


no it doesn't, just pass the parameter in the query string as they were
intended !!
Sep 30 '05 #8
On Fri, 30 Sep 2005 14:18:30 GMT, "Zoe Brown"
<zo***********@N-O-S-P-A-A-Mtesco.net> wrote:
It does seem to be much simpler that other methods, eg passing the
value with the URL etc.


no it doesn't, just pass the parameter in the query string as they were
intended !!


Zoe,

Not sure what you mean? Could you please explain?

It is the case, as was pointed out to me, that this method does not
work with Firefox so have moved to the form/URL approach.

Cheers

Geoff

Sep 30 '05 #9

"Geoff Cox" <ge*******@notquitecorrectfreeuk.com> wrote in message
news:ua********************************@4ax.com...
On Fri, 30 Sep 2005 14:18:30 GMT, "Zoe Brown"
<zo***********@N-O-S-P-A-A-Mtesco.net> wrote:
It does seem to be much simpler that other methods, eg passing the
value with the URL etc.
no it doesn't, just pass the parameter in the query string as they were
intended !!


Zoe,

Not sure what you mean? Could you please explain?

It is the case, as was pointed out to me, that this method does not
work with Firefox so have moved to the form/URL approach.


which is what I said. Just use the form and use a post or get to get the
data.


Cheers

Geoff

Sep 30 '05 #10
On Fri, 30 Sep 2005 18:58:23 GMT, "Zoe Brown"
<zo***********@N-O-S-P-A-A-Mtesco.net> wrote:

"Geoff Cox" <ge*******@notquitecorrectfreeuk.com> wrote in message
news:ua********************************@4ax.com.. .
On Fri, 30 Sep 2005 14:18:30 GMT, "Zoe Brown"
<zo***********@N-O-S-P-A-A-Mtesco.net> wrote:
It does seem to be much simpler that other methods, eg passing the
value with the URL etc.

no it doesn't, just pass the parameter in the query string as they were
intended !!
Zoe,

Not sure what you mean? Could you please explain?

It is the case, as was pointed out to me, that this method does not
work with Firefox so have moved to the form/URL approach.


which is what I said. Just use the form and use a post or get to get the
data.


Zoe,

OK - with you!

Cheers

Geoff



Cheers

Geoff


Oct 1 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Amr Mostafa | last post by:
Hello :) I'm trying to write a script that deals with a web service. I'm using NuSoap class. my question is : Can I pass some variables By Reference to the web service and get the result back...
40
by: Sonia | last post by:
Hi, Please look at the following code. This is a simple program for a game of craps - very basic. I have declared the gameStatus as global variable. I was wondering if there is a better way of...
3
by: Guru | last post by:
Hi , I tried the following 4 line of code and answer is what I never expected.I ran the code using C++ compiler(MS-Studio .net 03) also in Unix env.In fact the on Unix i got the correct (or...
11
by: comp.lang.php | last post by:
On one of my sites, I have a TCL CGI script that has a security hole in spite of it having effective server-side validation (the fact that it's CGI IS its security hole). The front end is a PHP...
8
by: Johnny | last post by:
I'm a rookie at C# and OO so please don't laugh! I have a form (fclsTaxCalculator) that contains a text box (tboxZipCode) containing a zip code. The user can enter a zip code in the text box and...
3
by: voro.cibus | last post by:
I have been reading up on this all day, and I can't find the answer (or more likely, don't understand the answers I have found) to my problem. I have a table that stores the name of my ascx page....
3
by: James Robertson | last post by:
I am new to the ASP and VB thing so be kind. Question I have is that I have created an ASPX web site to use as an E-Mail page. But I want to use this for a lot of users. Can I create the link on...
2
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would...
1
satterfieldben
by: satterfieldben | last post by:
I have a newbie question about passing variables between functions. I am wanting to use a drop down box to select a value. Then base on which was selected, it would create a variable and I would call...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.