To get a desired message as pop-up like
1. "Do you want to save?" with a YES/NO button
2. "Do you want to submit?" with a YES/NO button
we cannot achieve the same using Javascript. We can achieve using VB script (confirm.vbs).
Function vbMsg(isTxt,isCaption)
testVal = MsgBox(isTxt,4,isCaption)
isChoice = testVal
End Function
Here is the invoking js (confirm.js).
Here title/caption is nothing but the page heading.
var isChoice = 0;
function callAlert(Msg,Title){
txt = Msg;
caption = Title;
vbMsg(txt,caption)
if(isChoice==6){
return true;
}
return false;
}
Finally here is how we invoke it
function approveRequest(approvMsg,confirmMsg){
var confirm=callAlert(approvMsg, confirmMsg);
if(confirm) {
document.forms[0].action='abcApprove.do';
document.forms[0].submit();
}
}
JSP Page
<script type="text/javascript" src="../js/confirm.js" />
<script type="text/VBScript" src="../vbs/confirm.vbs" />
<input type="button" value="<bean:message key="request.btn.approve" bundle="gtem"/>"
onClick="approveRequest('<bean:message key="request.message.approveMessage" bundle="abc"/>','<bean:message key="common.message.confirmMessage" bundle="abc"/>');">
Application Resource Bundle:
common.message.confirmMessage = Do you really want to approve request?
request.message.approveMessage = Confirm
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment