Jump to content

Archived

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

Kris

return false

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?

Share this post


Link to post
Share on other sites
maybe nothing but put the semi colon after return false.

and why are you still using single quotes for html attribute values?? u naughty boy! ;)

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
Not to worry now guys, the 'return false' actually was working in the first place - Something else along the line wasn't!

Share this post


Link to post
Share on other sites

×

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.