1

I need to dynamically change form action link with javascript function which calculates and returns the action link base on some logic.

<form id="editForm" th:method="post" th:action="@{\''+linkProcess()+'\'}" th:object="${editObj}">
 //form content
</form>

 function linkProcess(){
 let link=//some logic to process link;
 return url;
 }

1 Answer 1

1

You can't call out to a JavaScript function in Thymeleaf, because Thymeleaf runs on the server and the JavaScript function runs in the user's browser.

Instead, set the action on the form directly in JavaScript using something like the following:

document.getElementById("editForm").action = url;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.