PDA

View Full Version : :: passing vaiarbles to other pages ::


babelfish
10-03-2002, 01:47 PM
how can i do this? u know, i see urls like dhsgbdhas.html?x=y is there a way to utilise this?

babelfish
10-03-2002, 04:00 PM
awwwwww :( all i want is a way to pass a variable from 1 page to another opening window...

i tried: NEWWINNAME.document.formname.textbox.value = 'hello'

on my function and it falls in a heap - i have no idea why!

any ideas?

adios
10-03-2002, 04:15 PM
That's two different questions: the first refers to passing data in a query string appended to a url, the second has to do with using a window variable name instead of a window name as a JavaScript 'handle' on the object.

var myWin = null;
myWin = window.open('blah.htm','theWin','.......etc.

'theWin' becomes the new window's name; it's managed by the system and is basically only used as a target name in HTML. 'myWin',on the other hand, is the handle to manipulating the window via JS:

myWin.document.formname.textboxname.value = 'hello'

Query strings:

http://developer.netscape.com/viewsource/goodman_url_pass/goodman_url_pass.html

ShriekForth
10-03-2002, 04:16 PM
You can parse the current location. I have posed a couple of ways to do that in the last week or so. But the idea behind it is the same.

var str = new String(document.location);
vars = str.split("?"); // split to get the location
if (vars.length > 1){ // catch an empty query string
str = vars[1];
pairs = str.split("&"); // get the name value pairs into an array.
for (i = 0; i < pairs.length; i++){ // cycle through the name value pairs
hold = pairs[i].split("=") // split them
}
}

That example will have only one set, the last set, so you should save hold off somewhere else.

You can use beetles (http://www.codingforums.com/showthread.php?s=&threadid=6038&highlight=getvars) as well, his is more generic, the one above was written for parsing a single value.

ShriekForth

babelfish
10-03-2002, 04:26 PM
i tried that tho ages ago...

there seems to be some wierdness surrounding this...

on the 1st page i have this:

<input type="button" name="go" value="Go!" onClick="openSlideShow('slideshow','slideShowWin','')">

with this function:

function openSlideShow(url,winName,features) {
slideShowWin=window.open(url,winName,features);
slideShowWin.focus();
slideShowWin.pause.value = 1000000
slideShowWin._slideshow.speedWhat.value='hello'
//slideShowWin.document._slideshow.speed.value = 'hello';
}

on the 2nd page i have this:

<input type="text" name="speedWhat" id="speedWhat">
its in a form called _slideshow

but all i get is that that particular field is null or not an object?!?!

even if i add document._slideshow.speedWhat.value='hello' to the javascript header on that page i get an error!?! but if i stick it in onLoad its fine - seems wierd to me...

basiaclly when i can get this working i can get on with the real use but i dont wanna overcomplicate this here - and i cant show the pages cos they are running on a test server that isnt viewable externally

adios
10-03-2002, 04:42 PM
even if i add document._slideshow.speedWhat.value='hello' to the javascript header on that page i get an error!?! but if i stick it in onLoad its fine - seems wierd to me...

It might be weird if HTML documents weren't parsed from the top down, <head> before <body>. Can't play with a form that doesn't exist yet. How 'bout:

slideShowWin.document._slideshow.speedWhat.value = 'hello';

babelfish
10-03-2002, 04:44 PM
i can grab stuff from the Url no problems - its just that u cant actually stick it in the url yourself -

basically this is the gist of what im trying to do:

we are creating a dynaimic webcam page of a large construction building - images are sent from a webcam into a dbase - then i pull the data from the dbase into a view that seperates each day/week/hour into clickable link...

now, i also want a time lapse animation of the project so far - BUT the images are 13k each, so a 56k user needs a diff gap between image transitions...

so i thought that i would get the slideshow to run at 3 speeds - slwo, medium and high, now, i can do this buy using 3 buttons but i wanted to do just pass the variable PAUSE from the 1st page to the 2nd - u cant just stick ?pause=3000 in the URL it dont work and i tried getting the 2nd page to do:

var PAUSE = window.opener.formname.checkbox.value

no joy

any ideas? this seems like it should be easy but all the things that should work arent?!!?

RoyW
10-03-2002, 08:12 PM
Have you read this thread?
http://www.codingforums.com/showthread.php?s=&threadid=4555

RadarBob
10-04-2002, 12:57 AM
RE: the code in the thread-link posted by RoyW.

"Looks like a cookie, smells like a cookie, but it ain't a cookie"

Alex Vincent
10-04-2002, 01:06 AM
Didn't I write a tutorial on this? :cool:

babelfish
10-04-2002, 09:52 AM
damn!

seems that lotus notes (the dbase system im using to get the images and the filetype) dont like ? in the url - must be as it uses it for its own devices :( any more ideas?

Owl
10-04-2002, 11:26 AM
Hi babelfish,

var PAUSE = window.opener.document.formname.checkbox.value

( •) (• )
>>V

babelfish
10-04-2002, 01:59 PM
im pretty sure i tried that already... :(

Mr J
10-04-2002, 06:00 PM
Not sure if this is of any help but:

In the calling document.



<script language="JavaScript">
<!--
function passdata() {
var str="Data Passed To Document"
location.href = 'page2.htm' + '?' + escape(str);
return true;
}
//-->
</script>

<a href="#null" onclick="passdata()">Pass Data</a>



In the called document. (page2.htm)

<script language="JavaScript">
<!--
var dataPassed = '';
if (location.search.length > 0)
dataPassed = unescape(location.search.substring(1));
document.write(dataPassed);
//-->
</script>



Just a thought.

gimpdog
12-12-2002, 12:20 AM
does anyone know how to get this to work using onsubmit to call the function. ive tried it and the passer page won't go to the location page

whammy
12-12-2002, 03:54 AM
gimpdog, you'd need to explain your specific problem in more detail in order for anyone to be able to help you.

gimpdog
12-12-2002, 05:06 AM
yeah, sry bout that...ive been knee deep in some code for a little too long. what i meant, which ive found another way around, was when i clicked on the submit button tied to an onSubmit which calls a function the location.href command inside that function wasnt taking. the page would not go anywhere. but ive just set the method on the form to get which appends info on to the url already.

thnx though whammy