score:0

Accepted answer

You can't do that directly, keep in mind that JavaScript is client-side technology and Scala template is backend one. That means that Play compiles the view long, long before the client (and its JS) will see it.

You have 2 solutions:

  1. Replace action attribute of form tag using JavaScript
  2. You can also use Play's JavaScript routes to create url (also using javascript after page rendering)

Related Query

More Query from same tag