Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
158
rated 0 times [  159] [ 1]  / answers: 1 / hits: 30784  / 9 Years ago, fri, september 4, 2015, 12:00:00

Can I call JavaScript function with return confirm(); in HTML onclick event or do I need to do function which contains confirmation and call to another function?



<button onclick=return confirm('Are you sure?'); saveandsubmit(event);></button>


Thanks in advance.


More From » html

 Answers
14

Add if condition



<button onclick=if(confirm('Are you sure?')) saveandsubmit(event);></button>


OR



<button onclick=return confirm('Are you sure?')?saveandsubmit(event):'';></button>

[#65191] Wednesday, September 2, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
deniseryannd

Total Points: 169
Total Questions: 85
Total Answers: 96

Location: Virgin Islands (U.S.)
Member since Fri, May 7, 2021
3 Years ago
;