This is a discussion on "Variable passing" within the JavaScript Forum section. This forum, and the thread "Variable passing are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Variable passing
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Hi,
I'm looking for an easy way to take a variable (i.e. myPageNumber) to another page. When I click on a link to the other page, I want the new page to 'remember' from which page a came. For some reason I don't want to use <history> or <cookies>. I read somewhere that this can be done via the url, but I'not sure how this exacty works, and how I can extract the variabe from the url (into the new page). Can anyone help me out here with a simple example what to do on both (sending and receiving) pages? Thankx, Hans |
|
|
|
#2
|
|||
|
|||
|
Re: Variable passing
Yes this can be done. I haven't got time to explain it now but will get back to you later.
|
|
#3
|
|||
|
|||
|
Re: Variable passing
Ok. Before we look at a solution, what information do you want to pass from page to page and why?
I ask you this in case the information could be sensitive in any way, in which case you would not want it appearing in the address bar of the browser. You also need to think about the fact that if this information was of a sort that could be hard-coded into the links, ongoing maintainance could quickly become a real pain. |
|
#4
|
|||
|
|||
|
Quote:
What I have is: a number of pages with a kind of storyline within time: let's name it storypage#1, storypage#2 ...... storypage#X a number of pages with a kind of subjectline' with certain subjects: let's name it subjectpage#1 .... subjectpage#X Another section contains the real info: let's name it infopage#1....infopage#x The infopages can be entered from both the storypages and subjectpages. What I would like to remember is when I enter an infopage from either the storyline pages or the subjectpages, is the storypage- or subjectpage number or variable, so that I can continue with my story or subject after reading the info. To make it more complicated: Sometimes I need to view more infopages before returning to either the original storypage or original subjectpage, so I figure that {javascript: history.back} won't help me, unless I can count the number of histories between entering and leaving the infopages. I hope I made myself clear, and I really appreciate your help. Regards Hans |
|
#5
|
|||
|
|||
|
Re: Variable passing
Ok, there are some limitations / problems with what you want to do.
You are assuming that the user is going to want to navigate the same way you would have. This second guessing could lead to the user becoming irritated and leaving the site altogether. You are effectively creating your own history chain which you will need to manage and pass from page to page. What happens if the user decide to use their back / forward button instead? Is this really viable? |
|
#6
|
|||
|
|||
|
Re: Variable passing
They need to click more 'backs' to return to the storyline instead of the link 'go back to the storyline' I would like to create. In fact it's even more complicated, because I use frames, and in some cases 3 frames change by leaving the storypath to the info-items, but it might be 2 frames in some cases.
So my thought was: if I remember were I came from by 'knowing' a number generated by the page I origianally came from, it looks easy to me to use a link 'go back' no matter where I came from, telling javascript if variable a = 1, b=4, c=8: go back to storyline page a, frame2 (buttons) page b (=4), frame 3 (topframe, naviagation) page c (=8) etc. I guess if the user is really interested in the storyline with the addition of extra info, the navigation I would like to provide is the easiest way....but I would like to find out myself if that's the case :-) |
|
#7
|
|||
|
|||
|
Re: Variable passing
Frames are the devils play thing and should be banned but in this case they are the solution to what you want to do. Set up a frame who's dimensions are such that the frame is not seen. Because that frame never changes, you can then set up a JavaScript variable in that frame which becomes your memory store. Set up an array which you operate as a last-in first-out stack. |
|
#8
|
|||
|
|||
|
Quote:
I'm not a javascript guru, which means I only use it for preloading images and simple functions as multiloads or simple tasks. That's why I needed some help in the first place....... Regards Hans |
|
#9
|
|||
|
|||
|
Re: Variable passing
You have obviously created quite a complex frame structure. Usually the frame structure doesn't change from page to page, just the elements that are in the various frames.
Can you not select a frame that is always there and place the necessary JavaScript in that? Alternative add another frame that will always be there. What are you using to produce your pages and frame structure? Do you know how to call functions in one frame from within another frame? |
|
#10
|
|||
|
|||
|
Quote:
This side is meant to be for multiple purpose: 1) A review for drawing and painting materials; 2) My personal story of my drawings; 3) overview of drawings without the story. When you enter the site, in the left frame you'll find the main menu, in the top frame navigation and (if available) submenu's, in the right frame the explanation of the topic. (Not every button is working yet). By clicking on TEKEN- EN SCHILDERMATERIALEN (drawing and painting materials) you'll see buttons appear in the top frame, related to this topic. Choose KLEURPOTLODEN (colourpencils);WATERVASTE KLEURPOTLODEN;option 5: Prismacolor Premier. You'll see that the top and right frame changes with every click. On this level the topic TEKEN- EN SCHILDERMATERIALEN will meet the storyline..... The (not yet a) link 'mandala's' should bring you back to..... By clicking DE REIS NAAR BINNEN (journey inside) - maart 2006 (march), please click on the thumbnail on this page, you'll find a short overview of this drawing. From here you'll get the option to travel further, see with which materials this drawing was made, or see other drawings. By clicking the link 'kleurpotloden' (not yet a link) will bring you to the info as explained earlier, but NOW I want to remember that I came from this page, so when I click 'mandala's' in the TEKEN- EN SCHILDERMATERIALEN section, I will come back here. I hope you'll see my point in choosing something like 'passing variables' to remember where I came from, because more drawings are made by the same drawing-materials. Regards Hans |
|
#11
|
|||
|
|||
|
Re: Variable passing
Had a look at you site and the code behind it.
What I'm thinking at the moment is that you could maintain an array as a variable as mentioned previously. Then when you call your function - multiload3, that array could be appended to one of the file calls, for example;
You could in theory maintain an array for each of the three frames. Am I making sense? |
|
#12
|
|||
|
|||
|
Re: Variable passing
Hi Geoff,
Thanks for the effort to look into the problem. Right now I have no clue what you mean, but I will have a look it it and try if I can make chocolat of it [ dutch expression :-) ]. If not, I will let you know later on. Thanx, Hans |
|
#13
|
|||
|
|||
|
Re: Variable passing
Quote:
I have had a look into this code and I found some examples which work for a single reference. Now I'm struggeling with how to use it in a <javacript:Multiload3>function. What I've done so far:
Can you please give me a clue ? Thanks, Hans |
|
#14
|
|||
|
|||
|
Re: Variable passing
Is there some reason why you can't call sendData() as the first line of code in your multiLoad3() function?
|
|
#15
|
|||
|
|||
|
Re: Variable passing
Quote:
parent.mainFrame.location.href is called in both functions with different arguments. I have no clue how to tell multiLoad3 to add the argument "?" + packed behind doc2, because that should do the trick (or not ?) Regards Hans |
|
#16
|
|||
|
|||
|
Re: Variable passing
Hi Geoff,
I already found out, I need to remove the second line from the multiLoad3 - function, and then it works perfectly. Thanx for pointing me in the right direction ! Regards Hans |
|
#17
|
|||
|
|||
|
Re: Variable passing
I hope the chocolate tastes good ;-)
I'm a plain chocolate fan myself. |
|
#18
|
|||
|
|||
|
Re: Variable passing
Quote:
But now I run into new challenges. I should probably open a new thread... What I want to know now: Is it possible to load a certain image into a table-cell depending on a certain variable-value which I have sent from one page to the other? e.g. value = 1 -> send value to second page and open here picture 1. and if so can this also be done with with a <a href=...></a> ? if the value > 0 a reference with a multiload-function containing data[1],data[2] and data[3] is added to the picture, (referring to my top,left en mainFrame of the leaving page), and if the value = 0 no reference should be added. Thanks, Regards Hans |
|
#19
|