fansa Posted January 7, 2009 Share Posted January 7, 2009 Hye all, I have some problem about message box.The message only run button OK but button CANCEL not function properly.Hope have anybody can help me to solve this problem.Attached here is the some of the coading function save() { var purchase = document.adjust.purchase if(disp_confirm2() == false){ return false; } return true } function disp_confirm2() { var r=confirm("Are You Sure To save?"); if (r==true) { return true; } else { return false; } } <input type="submit" class="button" name="Save" value="Save" onclick="save()"> Quote Link to comment Share on other sites More sharing options...
sniperscope Posted January 7, 2009 Share Posted January 7, 2009 I think you for got some else statement function save() { var purchase = document.adjust.purchase if(disp_confirm2() == false){ return false; } else { return true; } } function disp_confirm2() { var r=confirm("Are You Sure To save?"); if (r==true) { return true; } else { return false; } } <input type="submit" class="button" name="Save" value="Save" onclick="save()"> Quote Link to comment Share on other sites More sharing options...
fansa Posted January 7, 2009 Author Share Posted January 7, 2009 still same....if i put else statement..why?? Quote Link to comment Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 change both buttons to <input type="button" value="OK" onclick="disp_confirm(this.value.toLowerCase())" and <input type="button" value="CANCEL" onclick="disp_confirm(this.value.toLowerCase())"/> then have a function function disp_confirm(v) { if (v == 'ok') { // do whatever for OK } else if (v == 'cancel') { // do whatever for CANCEL } else { alert("Error: Invalid button"); } } btw this is a javascript question and will most likely get moved.. Quote Link to comment Share on other sites More sharing options...
fansa Posted January 8, 2009 Author Share Posted January 8, 2009 i already did..but on the screen button OK and button CANCEL appear, not window pop up that have button OK and CANCEL..erm,have i do any mistake again? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.