How can i get the value after the on Change for the dropdownlist without Model

hi,

i have tried everthing to get the new Value in OnChange event for a dropdown list without model. but i get always NOTHING

$ls_sku_field->onChange( function($val) use ($ls_stock_form){
$ls_stock_form->js()->submit();
$lv_value = $val;

        //return 'hallo';
      //  $args = $args;            
      //  $lv_form = $ls_stock_form;
      //  return 'hallo';
    }

Did i some mistake ? can someone post a solution ?

THX
Peter

Did you get your callback code called at all?

i have tried every thing. The callback was be called. I can see it wit breakpoint. But i do not know, how can I get the value :frowning:

BR
Peter

I seem to not understand what are you trying to do. But in an onChange event I think you have to return a js to be executed

hi Zak,
thanks for your answer.
i want to only catch the new value from dropdownlist if i select an entry.
an example from w3school


<form>
  Select your favorite fruit:
  <select id="mySelect">
    <option value="apple">Apple</option>
    <option value="orange">Orange</option>
    <option value="pineapple">Pineapple</option>
    <option value="banana">Banana</option>
  </select>
</form>

<p>Click the button to return the value of the selected fruit.</p>

<button type="button" onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
  var x = document.getElementById("mySelect").value;
  document.getElementById("demo").innerHTML = x;
}
</script>

</body>
</html>

BR
Peter

Hello again Peter.

If I understand your scenario correctly you might want to try two things:

$dropdown->jsInput()->val();

To get the value in a js callback

or

$dropdown_form->model['dropdown_field_name'];

If you are in the form’s on submit callback.

Hello Zak,

sorry for the later answer.
in the end, i have put the dropdown into a form and i get the value at last :slight_smile:

thx for your help

BR
Peter

1 Like

You’re welcome Peter