[Javascript] passing variables - basic question
Cheng, Kynan (London)
ChengKyn at exchange.uk.ml.com
Wed Apr 11 04:36:38 CDT 2001
awesome,
Thanks Rodney!
So the alternative would be to write a cookie from the first file and have
the second file read and parse that right?
Thanks
Kynan
> -----Original Message-----
> From: Rodney Myers [SMTP:rmyers at i-way.co.uk]
> Sent: 11 April 2001 10:23
> To: javascript at LaTech.edu
> Subject: Re: [Javascript] passing variables - basic question
>
> Kynan,
>
> Using the query string is a perfectly good way to do it. The alternative
> would be cookies.
>
> Thing to understand about using query strings with javascript is that
> there is no server-side-type mechanism for picking up values of
> name=value pairs. I believe in PHP it would be $selectedpicture ?
>
> In js all you are doing is parsing the query string. So
> href="picture.html?pictureone.jpg"
> could be used, just as well as
> href="picture.html?selectedpicture=pictureone.jpg"
> if that was all you were using the query string for in these pages.
>
> window.location.query gets you the string beginning with the "?" char.
> Except js may not believe it is really a string hence the ""+ in the
> line below which forces to string type.
>
>
> var qs = ""+window.location.query;
> qs=qs.substring(1);
>
> Now qs has the value of "selectedpicture=pictureone.jpg" or
> "pictureone.jpg"
> The second alternative would be less work to deal with, I think.
>
> hth
>
> Rodney
>
> "Cheng, Kynan (London)" wrote:
> >
> > Hi guys,
> >
> > I have not coded in Javascript before and I am trying to find out how to
> > pass variables from page to page, so I was wondering if someone could
> look
> > this over briefly:
> >
> > For example, if I have a page with thumbnail, and I'd like to call a
> page
> > that dynamically places the original photo into it (based on the
> thumbnail
> > clicked) does it go a little something like this?
> >
> > in index.html:
> > <a href="picture.html?selectedpicture=pictureone.jpg"><img
> > src="thumbnailone.gif"></a>
> >
> > in picture.html
> > (PHP version) <a href="index.html"><img src="<?php print $selected
> picture
> > ?>"></a>
> > (JS version) which doesn't work
> > <script>
> > document.write("<a href='index.html'><img src=", selectedpicture ,
> "></a>")
> > </script>
> >
> > Do i need to have some script which takes in the URL argument?
> > Is there another (better) way to pass variables?
>
>
> --
> Shop at ssistant Add-ons and Developer Workshops
> http://www.aflyingstart.net/addons/
> STILL PLACES OPEN on Fri 27 April workshop
>
> Courses in April
> Mon 23 : Making a Start in E-Commerce with Shop at ssistant
> Tue 24 : Meeting Business Needs with the Shop at ssistant Classic system
> Wed 25 : Building Better Shopping Pages with Shop at ssistant Classic
>
>
> Booking for these Shop at ssistant Classic courses at
> http://www.shopassistant.net/training/
> Or call 01256 880770
>
> Rodney Myers
> Based in Oxford, England
> Technical Director, Shop at ssistant eCommerce Solutions
>
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> http://www.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list