Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.