JS var from link...

Discussion in 'Web Design and Development' started by Me1000, Feb 5, 2008.

  1. Me1000 macrumors 68000

    Me1000

    Joined:
    Jul 15, 2006
    #1
    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,
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    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>
     

Share This Page