G
GiJeet
Hello, I'm trying to figure this code out.
<input type="submit" onclick="if(!confirm('Are you sure?') return
false; "... />
I know that if you return false in an event like this onclick it
prevents the default behavior of the event. So, in the onclick of a
button the default behavior is to submit the form.
Confirm returns the value 1 if the user clicks OK and the value 0 if
the user clicks Cancel and 1 is treated as true and 0 is treated as
false right?
so, if the user click OK, a 1 is returned but the ! turns it to false
and the form should not submit even thou the user click OK, and then
there's a return false right after the confirm function. so what's
happening here? do we even need the return false statement here?
TIA
g
<input type="submit" onclick="if(!confirm('Are you sure?') return
false; "... />
I know that if you return false in an event like this onclick it
prevents the default behavior of the event. So, in the onclick of a
button the default behavior is to submit the form.
Confirm returns the value 1 if the user clicks OK and the value 0 if
the user clicks Cancel and 1 is treated as true and 0 is treated as
false right?
so, if the user click OK, a 1 is returned but the ! turns it to false
and the form should not submit even thou the user click OK, and then
there's a return false right after the confirm function. so what's
happening here? do we even need the return false statement here?
TIA
g