CodeIgniter Forums
Javascript in form_open() - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Javascript in form_open() (/thread-60565.html)



Javascript in form_open() - El Forum - 04-24-2014

[eluser]Sceok[/eluser]
Hi everybody,

I've read many things but I haven't read a thing so far about the possibility of putting some Javascript in the opener tag of a form using the method "form_open()" from the Form Helper.

Just to show you why I'm asking this, there are cases when you may need to write that part in the form opener tag as a last attribute :

Code:
onsubmit="return(jsFunction())"
(didn't write the whole line, otherwise, it keeps on removing that part between code tags from the line when he displays it)

And in order to make sure my website stays portable, I'd preferred using the method from the Form Helper.

Anyone has information on it ? Or a solution ?

Thanks.


Javascript in form_open() - El Forum - 04-24-2014

[eluser]CroNiX[/eluser]
Look at the "Adding Attributes" section for form_open(), where you can add any extra key/value pairs:
http://ellislab.com/codeigniter/user-guide/helpers/form_helper.html


Javascript in form_open() - El Forum - 04-24-2014

[eluser]Sceok[/eluser]
Yeah thanks !!!
I had already tried this but I probably made a mistake while writing.
I tried again after reading your comment and yeah it works, probably my mistake.

Thank you for making me try that thing again ^^