setting parameter values?

  • Thread starter Thread starter Peter Goldfield
  • Start date Start date
P

Peter Goldfield

I've just about worked out how to put a picture on another page (form) but
am having trouble writing the parameter values in the URL (see thread
"picture in form" started 8th Feb)
The name of my hyperlink parameter is "pic" and the value should be
"mypic.jpg" .
If I copy the picture I want from the folder list it comes in as something
like:
file:///C:/My Documents/My Webs/currentweb/john/shows/name/details/mypic.jpg

I've tried playing around with shortening and replacing / with \ to say
"john\shows\name\details\mypic.jpg" but with no luck - any ideas what I'm
doing wrong?
 
Hi Peter,
If you had a link like this
http://you.com/page.htm?pic=pic.jpg
you should be able to retrieve pic as
<script type="text/javascript">
var a = location.href.split('=');
alert(a[1]);
</script>
this is an over-simplification so don't use it for anything else but sounds
like it will do the job in your case.

Jon
Microsoft MVP - FP
 
ouch Jon - and thanks - bit above my head. Do you mean I should junk all the
stuff Jim Buyens suggested and place that script somewhere on my form?
(feeling good that I can call it a script - yes?) And change my parameter
value to an external link?
doesn't take much to confuse me, sorry.....
 
I suppose what I'm looking for is an easy way to change parameter value path
to picture, which I have to do hundreds of times. I want to be able to copy
and paste something to avoid errors.....
 
Peter,

For normal image display:
1. Make sure you have the web open first.
2. If creating a new page, save the page first.
3. Drag the image from it folder, within the web, onto your page.
4. View image properties, and the path should be either just the filename or
.../images/filename.jpg

If you need to have a single page where you display different images, based
on a link and can use ASP on the server, then see:

http://www.ycoln-resources.com/resources/scripts/default.asp#script9
--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================


Jon said:
Hi Peter,
If you had a link like this
http://you.com/page.htm?pic=pic.jpg
you should be able to retrieve pic as
<script type="text/javascript">
var a = location.href.split('=');
alert(a[1]);
</script>
this is an over-simplification so don't use it for anything else but sounds
like it will do the job in your case.

Jon
Microsoft MVP - FP

Peter Goldfield said:
I've just about worked out how to put a picture on another page (form) but
am having trouble writing the parameter values in the URL (see thread
"picture in form" started 8th Feb)
The name of my hyperlink parameter is "pic" and the value should be
"mypic.jpg" .
If I copy the picture I want from the folder list it comes in as something
like:
file:///C:/My Documents/My Webs/currentweb/john/shows/name/details/mypic.jpg

I've tried playing around with shortening and replacing / with \ to say
"john\shows\name\details\mypic.jpg" but with no luck - any ideas what I'm
doing wrong?
 
Hi,
well not the alert - I just put that in to show how to retrieve the param,
you'd probably want to write out an image tag with the value of pic, we
might as well check pic has a value to be on the safe side -
<script type="text/javascript">
var a = location.href.split('=');
if(a[1])document.write('<img src="' + a[1] + '">');
</script>
it's simplified because you know you'll only be passing 1 param (pic) to the
page. Don't have any posts from Jim in this thread

Jon
 
Thanks Thomas,
I'm trying to avoid using ASP and have a lovely javascript? from Jim Buyens
in reply to my thread 8feb "picture in form" on this forum.
Trying to work out a way to get the path to the picture in the parameter
value of the link in a relatively simple, repetitive, way.
 
I don't have access to prior read messages.

The ASP method I show, requires no database, no major coding or ASP
knowledge, and the only page that must have the .asp extensions is the page
that displays the image.

However if you want to use JavaScript, then good luck.

--

==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
WEBMASTER Resources(tm)

FrontPage Resources, WebCircle,
MS KB Quick Links, etc.
==============================================
 
no no I'm sorry....
where should I look for your ASP method, sounds great. Thanks again for
your guidance...
 
Peter Goldfield said:
Thanks Thomas,
I'm trying to avoid using ASP and have a lovely javascript? from Jim Buyens
in reply to my thread 8feb "picture in form" on this forum.
Trying to work out a way to get the path to the picture in the parameter
value of the link in a relatively simple, repetitive, way.

I presume you mean the post I'm repeating below.

If so, let me begin with a piece of advice: When requesting help or
further information about a previous post, either:

o Post to the original thread, or
o Repeat the previous post, as I've done below.

The problem, you see, is that I've posted about 200 messages since
February 8, and I can't possibly keep all those conversations in my
head.

As to adding a path, if it's constant, change:
document.write('<img src="' + getqsvar("pic") + '">');
to
document.write('<img src="../images/' + getqsvar("pic") + '">');
or whatever your path happens to be. And remember this is the path
starting from the page that contains the script, and not the path from
the page that contains the link.

If the path can vary, just add it to the hyperlink, as in:
<a href="myformspage.htm?pic=animals/pethippo.jpg">
but this is message becaue the path (i.e. animals/)

o IS from the myformspage.htm page to the pethippo.jpg fiel, and
o IS NOT from the page that contains the link to pethippo.jpg.

Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------


Jim Buyens said:
-----Original Message-----
I have a great number of pages each with a different
picture. I link through to the same form from each page
and would like to "include" the picture from the page to
the form - a different picture from each page!!

Can anyone help - is there a sort of "include picture
from last page" button? Seriously.....

Add this script to the <head> section of your forms page:

<script>
function qsobj (){
var qvbl;
var qstring = "" + document.location.search.substring(1);
if (qstring != ""){
var qpairs = qstring.split("&");
for (i=0; i < qpairs.length; i++) {
qvbl = qpairs.split("=");
this["" + qvbl[0]] = unescape(qvbl[1].replace
("+"," "));
}
}
}
function getqsvar(qsvar){
if (qstr[qsvar] == null){
return "";
}else{
return qstr[qsvar];
}
}
var qstr = new qsobj();
</script>

Then, add this code where you want the picture to appear.

<script>
document.write('<img src="' + getqsvar("pic") + '">');
</script>

Then (and here comes the stinky part) modify each URL
that points to your forms page so it specifies a query
string value as shown below.

<a href="myformspage.htm?pic=pethippo.jpg">
 
A big thank you again to everybody.
I've sorted my problem in a way that others may find useful.
1. I've had a number of folders and files that had spaces in them - they
don't now! It was causing a big problem.
2. I placed Jim's script on page B (my form), by braving (for me) the HTML
tag - just once!
3. I used the parameter value box on the hyperlink from Page A to enter the
path and name of the image to be sent to page B
4. Because I'll be using the same but modified page A, hundreds of times, I
wanted to be able to change the Page A link parameter value easily by
copying and pasting.. I found that copying the name of the picture in the
folder list and pasting it into the value box gave me too much information
that had to be stripped out, BUT, right clicking on the name and copying the
path found in the properties and pasting that, worked fine.
 
Back
Top