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:
- Replace
action
attribute ofform
tag using JavaScript - You can also use Play's JavaScript routes to create url (also using javascript after page rendering)