473,836 Members | 1,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1708
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.h tm" onsubmit="windo w.name=this.Nam e.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="documen t.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************ *********@wanad oo.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.h tm" onsubmit="windo w.name=this.Nam e.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="documen t.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************ *********@wanad oo.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.h tm">
Enter your name :
<input type=text name="Name" onchange="go(th is.value);">
<input type=submit value=GO>
</form></html>

file 'page2.htm' :

<html>
<title>page 2</title>
<body onload="documen t.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.******@bluey onder.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************ *********@wanad oo.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.h tm">
Enter your name :
<input type=text name="Name" onchange="go(th is.value);">
<input type=submit value=GO>
</form></html>

file 'page2.htm' :

<html>
<title>page 2</title>
<body onload="documen t.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*******@notq uitecorrectfree uk.com> wrote in message
news:ua******** *************** *********@4ax.c om...
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

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

Similar topics

4
3603
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 in my variables ?? note1: I'm not the one who wrote the web service.. so I can't modify
40
3404
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 handling this (possibly via local variables) I am using that variable to keep track of the status of the game and pass it back to main() from craps() where I either increase or decrease a bank balance. Should this be handled with local parameters...
3
1891
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 expected answer). --> #include <cstdio> #include <iostream> using namespace std; void fn(int, int); main()
11
3108
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 script, and I am writing server-side validation onto it, however, it is required to redirect to the TCL CGI script because only a CGI script has the ability to access a group-accessible XML script on the back end. I had to take the whole thing...
8
4418
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 click a button to determine whether the zip code is unique. If the zip code is not unique, another form/dialog is displayed (fclsLookup) - lookup form/dialog. The zip code is passed to the lookup form/dialog by reference. I then load a...
3
3337
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. My main page can be called on to load any of the pages referenced in my table. Therefore, I have no @Register controls in my aspx file. What I do have is this dim myUC as control = Page.LoadControl("~/reqforms/" & GetReqForm(requestID))
3
1992
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 the WEB site to mail to passing a variable from the WEB site to the ASPX web site to E-Mail to? Hope I explained this correctly. This is a response from another group. There was no way for you to know it, but this is a classic asp newsgroup....
2
1970
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 that variable in another Java script. Sample script <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { len = document.formname.selectname.length i = 0 chosen = "none"
1
2237
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 that variable in another Java script. Sample script <SCRIPT LANGUAGE="JavaScript"> function GetSelectedItem() { len = document.formname.selectname.length i = 0 chosen = "none"
0
9671
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10549
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10592
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7792
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6979
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4456
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4019
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3116
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.