Click to See Complete Forum and Search --> : add or subract number in link
graphicpro
10-10-2003, 02:14 PM
in a pop-up window that has a series of pictures 1-15 that are navigated by <-- or --> buttons, i need to have the code open the same window with the new picture so if popup shows picture 5.jpg, back would go to 4.jpg and foward would show 6.jpg.
path would be: popupwin.htm?ID=5
back would be: popupwin.htm?ID=4
foward would be: popupwin.htm?ID=6
etc.
if ID = 1, back would be ID=15
if ID = 15, foward would be ID=1
need to set links and call jpg
tnx in advance...
jbergthorson
10-10-2003, 02:48 PM
not sure if i completely follow you..
you have a popup window that displays 1 picture and a <-- and a --> button.
When you click on <-- or --> you want the picture that is already displayed to change to the prev or next pic dependant on what button they hit?
To do this you want to reload the page with new picture based on the URL that is passed to it from when the user clicked the button?
so the window looks something like this:
----------------
|....My pic.....|
|....My pic.....|
|....My pic.....|
| <-- --> |
---------------
if you hit, <--, reload the page with popupwin.htm?ID=5
if you hit, -->, reload the page with popupwin.htm?ID=7
so in your <body> of the popup window you will want to put
<script language="javascript:drawThePic();"></script>
and then in the <head> put:
function drawThePic()
{
PicID = document.URL.slice(document.URL.indexOf("?")+1);
document.writeln('<IMG SRC="'+PicID+'.jpg">');
}
You would get the back and next links by doing something like:
thePicNum = document.URL.document.URL.slice(document.URL.indexOf("?")+1).substring(0,1);
backPic = thePicNum-1;
if(backPic <1) backPic = 15;
nextPic = thePicNum+1;
if(nextPic >15) nextPic = 1;
backLink = "popupwin.htm?ID="+backPic;
nextNum = "popupwin.htm?ID="+nextPic;
then you can use javascript to write the links:
document.writeln('<a href="'+backLink+'">');
document.writeln('<a href="'+nextLink+'">');
I hope that isn't too confusing... it was just off the top of my head
graphicpro
10-10-2003, 03:50 PM
jbergthorson,
thanks your reply... me i can't seem to get to work... included page.
<script language="JavaScript">
<!--
function drawThePic()
{
PicID = document.URL.slice(document.URL.indexOf("?")+1);
document.writeln('<IMG SRC="'+PicID+'.jpg">');
}
thePicNum = document.URL.document.URL.slice(document.URL.indexOf("?")+1).substring(0,1);
backPic = thePicNum-1;
if(backPic <1) backPic = 15;
nextPic = thePicNum+1;
if(nextPic >15) nextPic = 1;
backLink = "popupwin.htm?ID="+backPic;
nextNum = "popupwin.htm?ID="+nextPic;
//-->
</script>
</head>
<body>
<!-- Next line calls pic with *** the pic number i.e. 1 - 15 -->
<img src="../art1/a***.jpg" border="0">
<!-- Next to for foward and back -->
<document.writeln('<a href="disp.htm?ID='+backLink+'">'); target="_self"><img src="../art/back_over.gif" alt="" name="back_off" height="19" width="70" border="0" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('back_off','','../art/back_off.gif',1)"></a>
<document.writeln('<a href="'disp.htm?ID=+nextLink+'">'); target="_self"><img src="../art/forward_over.gif" alt="" name="forward_off" height="19" width="70" border="0" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('forward_off','','../art/forward_off.gif',1)"></a>
</body>
jbergthorson
10-10-2003, 04:11 PM
your first problem is:
the document.writeln has to be between a
<script language="javascript"> and </script> tags.
so where you want the pic in your body, go:
<div align="center"><script language="javascript">drawThePic();</script></div>
and where you want the links you would go
<script language="javascript">document.writeln('<a href="disp.htm?ID='+nextLink+'" target="_self">');
</script>
<img src="../art/forward_over.gif" alt="" name="forward_off" height="19" width="70" border="0" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('forward_off','','../art/forward_off.gif',1)"></a>
you would do the same as above for the <-- button, just changing your image and nextLink to prevLink.
I thought you knew javascript so i didn't bother explaining that you needed the <script> tags, sorry.
There may be more problems but that is a huge one for right now.
jason
graphicpro
10-10-2003, 06:16 PM
Jason,
see next
graphicpro
10-11-2003, 02:29 AM
got it to work with backPics fine but...
when trying to go to next pic, always goes to 1 (one) or 11 (eleven)
see code
function drawThePick() {
PickID = (window.location.search).split("=")[1];
document.writeln('<IMG SRC="art1/a'+PickID+'.jpg">');
}
function backPics() {
backPic = PickID-1;
if(backPic <1) backPic = 15;
document.writeln('<a href="dispa.htm?ID='+backPic+'" target="_self">');
}
function nextPics() {
nextPic = PickID+1;
if(nextPic >15) nextPic = 1;
document.writeln('<a href="dispa.htm?ID='+nextPic+'" target="_self">');
}
tnx andy