JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 19th, 2004, 03:37 AM
dryan83 dryan83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 15 dryan83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
global variable losing value

i have a switch statement that displays certain parts of the page depending on what option the user chooses. i then need this variable passed along in the url bar and if multiple choices are made, them variables must be passed along too. here is my code:

var list
//alert(list)

function show()

{
//PageIndex2=getCookie();

PageIndex2=document.form1.options.selectedIndex;
//alert(PageIndex2)
switch (PageIndex2)
{
case 1:
{
showexport1();
var data = '1';
list = ''
list = list+'?case1=1'
var url = 'http://Process/test_Search.asp'+list;
document.location.href = url;
}
break
case 2:
{
showexport3();
var data = '2';
list = list+'&case2=2'
var url = 'http://Process/test_Search.asp'+list;
document.location.href = url;
}
break

the problem is that the global variable loses the data from case 1 when case 2 is called. would it be because the page is refreshing every time a case is selected? any help would be appreciated?!!

Reply With Quote
  #2  
Old August 19th, 2004, 04:08 AM
DeepDown DeepDown is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Netherlands
Posts: 99 DeepDown User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 1 m 8 sec
Reputation Power: 10
Quote:
would it be because the page is refreshing every time a case is selected

yep...


I think what you basicly want is something like:

Code:
	// Initialize your list-variable
	var list;
	function initlist(){
		var thispage = window.location.href;
		if(thispage.indexOf('?')!=-1) 
			list = thispage.substring(thispage.indexOf('?'),thispage.length);
	}
	initlist();
	
	// setting some values to the list-variable in your case statement
	function setcaseinfo(){
		if(list=='') list = '?case2=2'
		else list += '&case2=2';
	}
__________________
** Don't expect me to code your needs, but if I am able to help, I'm willing. Shout, grab and use the hand!
** Man can no more own the land we walk upon, as they can lay claim on the air that we breath
** DeepDown I'm addicted to structures.... ohw and music
** Almost forgot I had an account here [*o*]

Reply With Quote
  #3  
Old August 19th, 2004, 04:20 AM
dryan83 dryan83 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 15 dryan83 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
any ideas on any other way to do this?!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > global variable losing value

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap