Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-27-2002, 12:45 PM   PM User | #1
phani
New Coder

 
Join Date: Aug 2002
Location: india
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
phani is an unknown quantity at this point
accessing the hidden variable from other file

how to access the hidden variable stored in one file in the other html file. or how to access the parameters passed on perform some action in other html file
__________________
phani
phani is offline   Reply With Quote
Old 11-27-2002, 04:17 PM   PM User | #2
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Huh? A hidden variable? Can you be more specific? What are you trying to accomplish?
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 11-27-2002, 05:38 PM   PM User | #3
brothercake
Senior Coder


 
Join Date: Jun 2002
Location: near Oswestry
Posts: 4,508
Thanks: 0
Thanked 0 Times in 0 Posts
brothercake is an unknown quantity at this point
perhaps he's talking about passing data through query strings
brothercake is offline   Reply With Quote
Old 11-27-2002, 06:31 PM   PM User | #4
beetle
Senior Coder

 
Join Date: Aug 2002
Posts: 3,467
Thanks: 0
Thanked 0 Times in 0 Posts
beetle has a little shameless behaviour in the past
Yes, that seems to make sense with the vocabulary he used. If that's the case, phani, you can use this function I wrote to extract all the GET parameters into an associative array
Code:
function parseGetVars() {
	var getVars = new Array();
	var qString = top.location.search.substring(1);
	var pairs = qString.split("&");
	var nameVal, val;
	for (var i=0; i<pairs.length; i++) {
		nameVal = pairs[i].split("=");
		val = (typeof nameVal[1] == 'undefined') ? '' : unescape(nameVal[1]);
		getVars[unescape(nameVal[0])] = val;
		}
	return getVars;
	}
var _GET = parseGetVars();
Of course, you can use any variable you like, I just chose _GET because it closely mimics the PHP counterpart.
__________________
My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
“Minds are like parachutes. They don't work unless they are open”
“Maturity is simply knowing when to not be immature”
beetle is offline   Reply With Quote
Old 11-28-2002, 07:13 AM   PM User | #5
phani
New Coder

 
Join Date: Aug 2002
Location: india
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
phani is an unknown quantity at this point
HTML

how to pass the parameters from one simple html page to another simple html page which is not having any relation between them....without having any server concept...
can i get any sample application with code
__________________
phani
phani is offline   Reply With Quote
Old 11-28-2002, 07:18 AM   PM User | #6
Roelf
Senior Coder

 
Join Date: Jun 2002
Location: Zwolle, The Netherlands
Posts: 1,110
Thanks: 2
Thanked 28 Times in 28 Posts
Roelf is on a distinguished road
if you don´t open the second page from the first one, use cookies. do a search in this forum for "cookies" it should return "some" results
Roelf is offline   Reply With Quote
Old 11-28-2002, 08:56 AM   PM User | #7
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
...or use window.name if you are not using frames/iframes

set it in a page:
window.name="blah";


you can access it in another page even if it is not opened from the page where you set the window.name:

alert(window.name)
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 11-28-2002, 09:18 AM   PM User | #8
phani
New Coder

 
Join Date: Aug 2002
Location: india
Posts: 74
Thanks: 0
Thanked 0 Times in 0 Posts
phani is an unknown quantity at this point
not getting the value of the hidden variable in the second html form

Hi glenn i have two html pages like this but i am not getting the value of the hidden variable in the secod form..even we assign some name to the window here is my two html pages can u help me

first html file (one.html)

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<script>
window.name = "hello";
alert(window.name)
</script>
<BODY BGCOLOR="#FFFFFF">
<form action = "two.html">
<input type="hidden" name = "vamsi" value = "hi">
<input type="submit" name = "go" value = "Submit">
</form>
</BODY>
</HTML>

second html file (two.html)

<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<script>
alert(hello.doucment.forms[0].vamsi.value)
</script>
</BODY>
</HTML>


can i get that vamsi.value in the second html page...if so plzz let me know how it should be done...
__________________
phani
phani is offline   Reply With Quote
Old 11-28-2002, 09:24 AM   PM User | #9
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
in first page:

<script>
window.onload = function(){window.name=document.forms[0].vamsi.value};
</script>
<BODY BGCOLOR="#FFFFFF">
<form action = "two.html">
<input type="hidden" name = "vamsi" value = "hi">
<input type="submit" name = "go" value = "Submit">
</form>


in second page:
<script>
alert(window.name)
</script>
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:27 AM.


Advertisement
Log in to turn off these ads.