Yes/No Confirm Message in Javascript

Swity
Kilo Explorer

Hi,

Can anyone help out with how to get Yes/No in confirm message. If not these then at least tell me if we can make Cancel as the default value in Confirm message of java script.

I need to show this Yes/No message if user clicks on Cancel change UI action.
Currently I have just added confirm message which displays OK & cancel buttons. Over here also, user wants cancel to be a default value whereas we have Ok as an Default Value.

Thanks in Advance!

Regards,
Swity!!!

3 REPLIES 3

gaidem
ServiceNow Employee
ServiceNow Employee

This sort of thing is best to check on a general JS site like W3:

http://www.w3schools.com/js/js_popup.asp

Checkout the confirm button section.


Swity
Kilo Explorer

Thanks matt!!
Already searched in all sites... but didn't got any so thought to ask if anyone has done like this before then it would be very helpful!


benn23
ServiceNow Employee
ServiceNow Employee

Name: Cancel
Action Name: cancel_me
Show update & Client = checked
onClick = cancelClient()
Script:

function cancelClient(){
var ans = confirm("Are you sure?");

if(ans == false){
return false;
}
else{
gsftSubmit(null, g_form.getFormElement(), 'cancel_me');
}
}

if(typeof window == 'undefined'){
fireMeUp();
}

function fireMeUp(){
current.state = '4';
current.work_notes = "Cancelled!";
current.update();
gs.addInfoMessage('Change Cancelled.');
action.setRedirectURL(current);
}