Jump to content

return false


zq29

Recommended Posts

I'm needing to trigger a JavaScript function "on submit" of a form, but I don't want the form submitted to the script denoted in the action attribute. As far as I was aware, this would be done by adding in a 'return false' within the 'onsubmit' attribute, like so:
[code]<form name='edit_user' action='insert.php' method='post' onsubmit='sendRequest(); return false'>[/code]
Although, when clicking the submit button within this form, in FireFox, it submits and goes to insert.php. In IE, it just prompts me to download insert.php...

Am I missing something?
Link to comment
https://forums.phpfreaks.com/topic/25290-return-false/
Share on other sites

[quote author=ToonMariner link=topic=112914.msg458502#msg458502 date=1161946536]
maybe nothing but put the semi colon after return false.[/quote]
No luck there :(
[quote author=ToonMariner link=topic=112914.msg458502#msg458502 date=1161946536]and why are you still using single quotes for html attribute values?? u naughty boy! ;)
[/quote]Because I'm actually echo'ing that code from within some PHP, and I couldn't be arsed to escape double quotes!
Link to comment
https://forums.phpfreaks.com/topic/25290-return-false/#findComment-115306
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.