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">