0

My problem is exactly as the title of my post shows. How should I call a javascript function inside the form_submit hook?

I just need to call a function which is previously defined in a javascript file and and is added to drupal form. How should I call the function?

I have tested submit() event in Jquery. The problem with it is that it starts to be executed as soon as the submit button is pressed.

I need a strategy which can cause the execution of that javascript function INSIDE the form_submit hook, not before it.

I would appreciate if anyone can help me.

  • You can't execute javascript on the server side (well, you can, but not in the way you're suggesting) – Clive Nov 18 '14 at 14:43
  • Well, you're completely right! I think it would be possible by using an Ajax button and it's callback and using the ajax_command_invoke... , what do you think? – Ehsan Nov 18 '14 at 15:32
  • 1
    Not understanding the use case here. I feel that you've got your logic flow tangled... what does this js accomplish exactly? – murraybiscuit Nov 18 '14 at 16:45
  • Well, I have found the answer, and I will put it here for everyone to use it. – Ehsan Nov 19 '14 at 9:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.