Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Me1000

macrumors 68000
Original poster
Jul 15, 2006
1,794
4
not a big javascript guru so I need some help...

this is my JS

Code:
<script language="JavaScript">
					function myConfirm(){
					var answer=confirm("Are you sure you want to remove this image \? If this image is in use some items may not display correctly.")
					if(answer)
					window.location="image.php?in=remove&previmage=IMAGEVAR"
					
					}
			</script>

the link to call up the function...

Code:
<a href="javascript:void(0)" onclick="myConfirm()">[Remove Page]</a>


now, I need to be able to define the var IMAGEVAR in the link, so that when it when you click it it redirects to a different page based on whatever the IMAGEVAR is.

for example, the image is '16' when you click the link, it needs to ask you to confirm (which it does fine) then redirect you to
Code:
image.php?in=remove&previmage=16

can someone give me some pointers?
or point me to a site that can help me with this?

Thanks,
 
The question isn't clear, but see if this is what you're after.

Code:
function myConfirm(IMAGEVAR)
{
  var answer=confirm("Are you sure you want to remove this image \? \
If this image is in use some items may not display correctly.");
  if(answer)
    window.location="image.php?in=remove&previmage="+IMAGEVAR;
}

HTML:
<a href="#" onclick="myConfirm('16'); return false;">[Remove Page]</a>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.