Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
ravi1989
Posts: 773
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

How to pass parameter to other screens

Hi show to pass parameter acutually upto two parameter its fine for me m but i am not able to pass 4 param.

window.location.href="route.html?RID="+r[id].RID+"&StationCode="+stationCode; uto this fine...


function getParams()
{
	var idx = document.URL.indexOf('?');
	var params = new Array();
	if (idx != -1) 
	{
		var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
		for (var i=0; i < pairs.length; i++)
		{ 
			nameVal = pairs[i].split('=');
			params[nameVal[0]] = nameVal[1];
		}
	}
	return params;
}

 var params = getParams();
		     var parameter1 = unescape(params["RID"]);
		     var parameter2 = unescape(params["StationCode"]);
		     ***********Two param is fine********





if i want to pass 4 param it not satifying

 window.location.href="route.html?RID="+r[id].RID+"&StationCode="+stationCode+"&destinationStationName="+"gjg"+"&stationName="+stationName;

  var params = getParams();
		     var parameter1 = unescape(params["RID"]);
		     var parameter2 = unescape(params["StationCode"]);
		     var parameter3 = unescape(params["stationName"]);
		     var parameter4 = unescape(params["destinationStationName"]);
		     alert(parameter3);
		     alert(parameters4);

alert are undifined

 

Please use plain text.
Developer
nunodonato
Posts: 313
Registered: ‎03-28-2012
My Device: Curve 9360, Playbook, BB10 Dev Alpha
My Carrier: TMN

Re: How to pass parameter to other screens

Hi ravi.

First of all , its a really bad idea to have the windows change its location like that in a webworks app. You should change the content dynamically without needing to change pages. bbUI, for example, does that in a very simple way for you.

Regarding your code, I copied and adapted it to run with a fixed string (so that I didn't need to change page) and it detected the 4 parameters without problems. Did you run it thru the inspector to check where the problem might be?

cheers
Nuno
theBBthing.wordpress.com - my BlackBerry development blog: news, tips and tutorials
bitoutsidethebox.com - re-imagining digital solutions


Please use plain text.
Developer
ravi1989
Posts: 773
Registered: ‎07-21-2012
My Device: 9810
My Carrier: 0

Re: How to pass parameter to other screens

can you explain in detail or give some example.

 

Actually i am working in all platform not only in blackberry ..

 

can you explain to pass parameter 

 

 

Thanks

 

 

 

Please use plain text.
Developer
Developer
LBP
Posts: 607
Registered: ‎04-29-2011
My Device: PlayBook 16GB, BB10 LE Z10 (red)
My Carrier: none

Re: How to pass parameter to other screens

Again nuno is really right. I wouldn't add the parameters to the page.html, instead I suggest to use sessionStorage to storage parameters if needed and pass in that way between screens.

 

For switching screen have a closer look what UI frameworks like bbUI.js can do for you. I think there are a lot of discussions in the past days about frameworks. Using JavaScript you do not need to switch complete files, you could also use one file and only show + hide the content needed for the "screen" you want to present to the user.


"Like" if you liked the post.
"Accept as Solution" if the post solves your question.
Please use plain text.