Making a confirm box
I am trying to make my own dialog box. I want to use jquery for this. For
some buttons on my site I need a confirmation dialog (like "Are you sure
you want to delete" yes/no). When the dialog is active, the rest of the
site should not be clickable.
So, I made this:
<div class="overlay" id="overlay" style="display:none;">
<div class="overlaycontent" id="overlaycontent">
<div id="overlaytext" class="overlaytext ">
<span id="overlaymessage" class="mediumtext bold">Deze klant
verwijderen?</span>
<br><br>
<button id="nobutton" class="button1 highbutton hand"
onclick="confirmno()">Nee</button>
<button id="yesbutton" class="button2 highbutton hand"
onclick="confirmyes()">Ja</button>
</div>
</div>
</div>
ID overlay is over the whole page. ID overlaycontent creates a white box
on top of it. ID overlaytext centers the message ID overlaymessage
contains the question/message. ID nobutton is the button to say no :) ID
yesbutton is.. guess what :)
Now, the javascript to display a message:
function confirm(message,nobutton,yesbutton){
$('#overlaymessage').html(message);
$('#nobutton').html(nobutton);
$('#yesbutton').html(yesbutton);
$('#overlay').show();
}
function confirmno(){
$('#overlay').hide();
}
function confirmyes(){
????
}
So far, it works fine (except the yes button of course, please read
further on), but for the next step I lack the knowledge. Say that I have a
button somewhere to delete a user on my website.
<button class="redbutton" onclick="deleteuser(22)">
The button needs javascript like:
<script language="javascript">
function deleteuser(userid){
confirm('Delete user?','No','Yes');
??????
}
</script>
Now where the question marks are, I want the function to do something
based on the fact the user clicked yes or no. How to catch this? I don't
have any idea. Please help me out. I don't want to use Jquireui.dialog.
No comments:
Post a Comment