Sorry for not clarifying. action=delete is just something that I want sent through in the query string, it has nothing to do with javascript.
Let me explain why I am needing this function: I have a large listing of assets that are in my system. I have created a generic "delete" button bellow all of these assets, which I would like to use to delete these. The way my system is set up, is you pass a specific URL, with something like action=delete and it will delete the asset at that URL. But since I only want to use that generic "delete" button, I need to figure out a way to click an asset, and transfer the URL, confirmation, etc. to my generic delete button. That way, I can use this for all the assets, just selection one, then click the delete button. Rather than having a seperate delete button for each asset. Here is what I was working on as a newer idea of this concept, but again, it is not seeming to work. $("#test").click(function() { var answer = confirm("Are you sure you want to delete this asset?"); if (confirm == true) { $("#test2").click(function() { $.ajax( {type : "POST", url : "http://www.puc.edu? action=delete" }); }); } }); <a id="test" href="#">Remove</a> <a id="test2" href="#">Add</a> So, when you click remove, and you confirm, it will add a new click event to test2 and allow you to click that link to pass the URL to the system. Still working on how to pass the URL of the first clicked asset though... On Jul 18, 12:11 pm, Mike Alsup <[EMAIL PROTECTED]> wrote: > > I do not really want to use an inline onclick, but I am a javascript > > newbie, and I was unsure how to still pass the two variable to the > > function if I did not do it inline. How could I rewrite this so that > > my function will still work, but "re-factoring" as you say? > > You never showed us where "action" comes from or why "assetid" is > needed, but here's a quick refactoring: > > $('a').click(deleteAjaxAsset); > > function deleteAjaxAsset() { > var url = $(this).attr("href"); > if (action == "delete" && > confirm('Are yous ure you want to delete?')) { > $.ajax({ > type: "POST", > url: url + "?action=delete" > }); > } > return false; > > }; > > You could also get rid of the named function deleteAjaxAsset > altogether and use an anon fn instead. But that's just a matter of > style. > > Mike