Getting values from a javascript(var)

It would be possible to get the value of the variable within a <% = =>

<script>
function displayResult() {
    var x = document.getElementById("Test").value; # I need to get the value of this variable

    var controller_checkoutdomain = "<%= inspect MyprojectWeb.RequestController.checkout_domain('x') %>"; # The problem is here, he can't get this variable X, because he is accessing a controller.
    
  document.getElementById("myHeader").innerHTML = controller_checkoutdomain;
}
</script>

As mentionned in your previous post, it will not work that way… because there is no way to communicate back and forth between backend and frontend by just reading/writing variables. And even if You could, You would need a mecanism to update DOM.

It really is a good fit for LiveView, and it is not complicate at all, just update a value on a phx.submit event.

100% Elixir, no javascript needed. Isn’t it what You are looking for?

1 Like

It would really be ideal for me,
I’m just having trouble

I’ll keep trying here