PDA

View Full Version : JS var from link...




Me1000
Feb 5, 2008, 07:00 PM
not a big javascript guru so I need some help...

this is my JS


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

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



angelwatt
Feb 5, 2008, 07:10 PM
The question isn't clear, but see if this is what you're after.

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;
}

<a href="#" onclick="myConfirm('16'); return false;">[Remove Page]</a>