thewooleymammoth Posted August 7, 2009 Share Posted August 7, 2009 Although my script is using ajax, my problem is in the javascript Im using an editor that formats text called openwysiwyg, and im using ajax to write the content of the editor to a file. So i need to get the value of the textarea. the problem is, the editor must be showing the text the user types in a different feild, then when the form is submitted, inserts teh text into the feild. So what i need to do is do and onclick='$('textarea').submit();' and then return it false so that the form doesnt actually change. Ex: <html> <head> <script type='text/javascript'> function get_value() { var val =$('ta').value } </script> </head> <body> <form onSubmit='return false;'> <textarea id='ta'></textarea> <button onclick='$('ta').submit(); get_value();'>update</button> </form> </body> </html> however the above code doesnt seem to work, the form still submits. if anyone could help me find a way to do this, it would be most appreciated, thanks. Im using prototype btw. and here is a link to a demo of openwysiwyg http://www.openwebware.com/wysiwyg/demo.shtml Quote Link to comment https://forums.phpfreaks.com/topic/169275-onclick-submit-and-return-false/ Share on other sites More sharing options...
Psycho Posted August 8, 2009 Share Posted August 8, 2009 When a form submits when you have a return false to prevent it from doing so, that typically points to a javascript error that is occurring - which prevents the return false from triggering. In this case I see at least one problem on the button object. You are defining the onclick function within single parens, but then you have parameters inside the onclick trigger action that also has single parens. Once the processor hits the 2nd single paren it thinks that is the end of the trigger code. Try this <button onclick="$('ta').submit(); get_value();">update</button> Quote Link to comment https://forums.phpfreaks.com/topic/169275-onclick-submit-and-return-false/#findComment-893473 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.