You'll need to either do this:
onclick="deleteAsset('Do you really want to delete
this?','delete','#a221','http://www.puc.edu');">

(Note the "#" before the id)

Or this:
$('#' + assetid).hide();

The reason is that otherwise, jQuery is looking for tagNames 'a221' which won't find anything. The selector needs that "#" to know to look for an id.

-- Josh


----- Original Message ----- From: "hubbs" <[EMAIL PROTECTED]>
To: "jQuery (English)" <jquery-en@googlegroups.com>
Sent: Tuesday, April 29, 2008 11:39 AM
Subject: [jQuery] Adding function argument into jquery



I wrote a small script that brings up a confirm dialog, and if the
user clicks ok, it will hide a div, and then post a URL.  I am using
the assetid argument from my function, and I want to use that with the
jquery .hide function, but it does not seem to work.  What have I done
wrong?  It seems like it is not passing assetid into the .hide()
function.

<script type="text/javascript">
function deleteAsset(message, action, assetid, asseturl) {
  var confirmDelete = confirm(message);
  if (confirmDelete == true) {
     if(action == "delete") {
        //Add jQuery function to hide the asset from the users view
        $(assetid).hide();
        $("#announceItemFull").html("");
        //Use ajax to post the URL so that our trigger will delete
the selected asset
        $.ajax( {
           type : "POST", url : asseturl + "?action=delete" }
        );
        }
     }
  }
</script>

<a href="#" onclick="deleteAsset('Do you really want to delete
this?','delete','a221','http://www.puc.edu');">Delete</a>

Reply via email to