Confirm Save During Onchange Of Drop Down
Onchange of select option I am confirming the user whether to save or not the changes. If user selects OK , I am submitting the form automatically.ie. onchange='if(confirm('Save?')
Solution 1:
Try this, don't think you can accomplish it without some manual work.
<scripttype="text/javascript">var ddHelper = {
previousIdx: null,
store: function(e, dd) {
this.previousIdx = dd.selectedIndex;
},
confirm: function(e, dd) {
if(!window.confirm('Save?')) {
window.setTimeout(function() { // Think you need setTimeout for some browsers
dd.selectedIndex = ddHelper.previousIdx;
}, 0);
}
}
};
</script><selectonfocus="ddHelper.store(event, this)"onchange="ddHelper.confirm(event, this"></select>
Solution 2:
If the input values come from any Database, load those again in the field when user press cancel.
Post a Comment for "Confirm Save During Onchange Of Drop Down"