PDA

View Full Version : Updating variables between windows


mpclubfoot
10-09-2002, 01:04 AM
Hello,

Background
My company has several retail outlets located in different states. Different vendors supply these outlets with goods, depending on the location. The vendors do not all offer the same catalogue of goods and do not have the same prices for those goods they sell in common. Thus, each of our outlets offers a slightly different list of items at different prices.

The Goal of the Project
I am building a web site for my company. There is a separate branch in the site for each of our retail locations. I wish to add a price list for each specific location. Since each list will be different, I want to create a general template, then fill in the items and prices dynamically.

The Project So Far
The pages for the individual locations and the template price list page all share an external .js file. This file includes a function to open a new window, a price array for each location and a set of functions that will dynamically load the contents of an array into the price list template. All of this works.

The Problem
I need some way to pass a value from the calling window to the price list window that will identify the caller. In other words, when the price list is opened from the Store A page, the value 'store_a' should be passed to the external .js file, where it is used in a switch statement to determine which price array is loaded into the template.

I have been all over javascript manuals and web sites trying to figure out if and how this can be done. I would very much appreciate some help.

Thanks,
Christian Hankel

ecnarongi
10-09-2002, 02:37 AM
how you come across I almost feel like charging ;) ok, let me make sure we are on the same page. Basically you want to pass values which you get from page A to page B and use that value to determine which price is display on the page B?

if so I would put the needed value in a hidden form element then grab that element on the page B like so

var val = location.search.substr(1).split("NAMEOFHIDDENFORMELEMENT=")

then do something like this
var results = val[val.length-1]
you have to do this because you get one element too many

then I would use results as my value in my switch statement. Tell me if that helps. Oh yeah this is the best damn programming forum period :)

adios
10-09-2002, 02:56 AM
http://developer.netscape.com/viewsource/index_frame.html?content=goodman_url_pass/goodman_url_pass.html

mpclubfoot
10-11-2002, 02:41 PM
You both rock! With the suggestions and the article, I was able to code up a solution that does exactly what I need. Thanks again!