views:

62

answers:

1

Hello All,

I am having a confirmation box after clicking on the "Delete " link in the jsp. Now the problem is that the success deletion page is showing in the same window.

I would like to show it in a pop up window.

I tried to use the javascript onclick(), but it is not wotking. So, how can I do that?

<script type="text/javascript" src="jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="jconfirmaction.jquery.js"></script>


<script type="text/javascript">

            $(document).ready(function() {


                $('.ask-plain').click(function(e) {

                    e.preventDefault();
                    thisHref    = $(this).attr('href');

                    if(confirm('Delete this record?')) {
                        window.location = thisHref;
                    }

                });

                $('.ask-custom').jConfirmAction({question : "Anda Yakin?", yesAnswer : "Ya", cancelAnswer : "Tidak"});
                $('.ask').jConfirmAction();
            });

        </script>

<meta http-equiv="content-type" content="text/html; charset=utf-8" />


<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
window.open(href, windowname, 'width=750,height=430,scrollbars=no');
return false;
}
//-->
</SCRIPT>

---Delete image
<td  width="3%" align="left"><a href="cir_delete.jsp?cir_id=<%=rs.getString("cir_id")%>" class="ask"><IMG SRC="12.png" ALT="Delete" BORDER="0"></a></td>

Thanx

A: 

when you click on delete, the confirmation box is shown and afterwards the form is submit.

What you need to do is submit the form trough jquery, cathc the result and show pass it to a popup box. I will give an exmaple soon.

I have done this once with jconfirm:

<script type="text/javascript">
        $(document).ready(function(){
            // give all your delete links a class="del" then when this is clicked, execute following:
            $(".del").click(function () {
            //get the href from th link you clicked
            var href = $(this).attr("href");
                activate JConfirm
                jConfirm('Can you confirm this?', 'Confirmation Dialog', function(r) {
                  // if confirm is clicked: 
                  if(r){
                       //post the form serialised to the url
                       $.post(href, $("#yourtestform").serialize(),
                          function(data){
                            // the posted form will return html data, load this data in a hidden div
                            $('#loadhtml').html = data;
                            // now that the data is loaded, open a colorbox with the hidden div as content (don't forget to include the colorbox.js
                            $('#loadhtml').colorbox();
                          };
                       );
                   }
                   //if the person clicked cancel: do nothing
                   else{
                        return false;
                   }
                });
                // insure that the form doesn't post itself again after jquery is finished
                return false;
            });
        });
    </script>

I assume you want to use a modal popup like colorbox or something define a div at the bottom where you can load html in after the post and hide it:

<div style="display:hidden" id="loadhtml">
</div>
Nealv
Sorry, can you please explain a little bit more in //call the popup box function that load html because I am a little bit confused
maas
Now, should I remove completely my code ? and replace it with the one you have posted?
maas
I would do so, but I hope you understand what the code does.
Nealv
I have added some comment, it might not be syntax correct, because I just wrote it here, and didn't test it in a browser or anything. but I am sure the basics will work and the flow will work
Nealv
Were you able to get it running ?
Nealv
No, Sorry I failed
maas