473,399 Members | 3,302 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 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 1677
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.