0

I have a dropdown list:

<select id="sel">
<option value="1">test1</option>
<option value="2">test2</option>
<option value="3">test3</option>
</select>

And I get the selected value as such:

var e = document.getElementById("sel");
var val= e.options[e.selectedIndex].value;

But what I need is to use the "val" variable in a play framework Scala if sentence like:

@if(svor.rettsvar == val){
    <p><b>@svor.svor_texti</b></p>
}

and to make it update if I change the selected value.

Best regards, Björn.

1 Answer 1

0

You can't mix Scala and JavaScript scopes.... Actually I have no even idea, how to explain it :/

Scala syntax is compiled at the runtime to some HTML code, and JavaScript is performed on the client side, so it's not possible to interact the Scala with JS... If you'll look into HTML code generated from Scala view, you'll understand.

Most probably you can resolve your problems with using ONLY JS conditions.

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.