File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes javascript confirm  onclick event using smook.js Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript confirm  onclick event using smook.js" Watch "javascript confirm  onclick event using smook.js" New topic
Author

javascript confirm onclick event using smook.js

Ravish Srivastava
Greenhorn

Joined: Sep 05, 2011
Posts: 23
Hi,

I am using smook.js for confirmation from user. i want to get a record id in the javascript function defined for smook.js like below. once user confirms, i can deleted that record.
THis is my JSP script part:

<script>
function tstconfirm(){
smoke.confirm('Are you sure you want to delete this record?',function(e){
if (e){
smoke.alert('Confirmed');
// Want to get the selected record ID here, so that i can call a ajax request to delete the record.
}else{
smoke.alert('Canceled');
}
});
}
</script>
This is my JSP body part:
<div>
<ul id="mytitle">
<li>
<p id="r_id">Record Id</p>
<p id="r_nam">Record Name</p>
<p id="r_des">Record Description</p>
<p id="r_typ">Record Type</p>
<p id="r_action">Delete</p>
</li>
</ul>
<ul id="mylist">
<c:if test="${!empty allrecorddata}">
<c:forEach items="${allrecorddata}" var="recordInfo">
<li>
<a href="editrecord.html">
<p id="r_id">${recordInfo.getId()}</p>
<p id="r_nam">${recordInfo.getName()}</p> // Record Name
<p id="r_des">${recordInfo.getDesc()}</p>
// Record Description
<p id="r_typ">${recordInfo.getType()}</p>
// Record Type
<p id="r_action"><a class="delete" onclick="javascript:tstconfirm();">Delete</a></p>
</a>
</li>
</c:forEach>
</c:if>
</ul>
</div>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

I can find no information about smook.js; what is it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ravish Srivastava
Greenhorn

Joined: Sep 05, 2011
Posts: 23
Bear Bibeault wrote:I can find no information about smook.js; what is it?


http://smoke-js.com/
Ravish Srivastava
Greenhorn

Joined: Sep 05, 2011
Posts: 23
Hi, I could able to resolved bit as, on my java script call i m passing the record id as :
onclick="javascript:tstconfirm('${recordInfo.getId()}');"


and java script method written as :

function tstconfirm(recId){
smoke.confirm('Are you sure you want to delete this record?',function(e){
if (e){
smoke.alert('Confirmed');
alert(recid); // This place I am able to get the correct record id
// here i can call the ajax function to delete the record.
}else{
smoke.alert('Canceled');
}
});

Now issue i am facing is alert "Confirmed" and alert(recid) display simultaneously, at this point browser not waiting Confirmed event from user, it goes ahead and print alert(rec id) too. It means that record gets deleted without user select "Confirmed". what if user decide to not to delete it using "Esc" button from key board.
}
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: javascript confirm onclick event using smook.js