Dynamic hight of a drop down possible?

dimna 29 Sep, 2015
Hello,
I have a drop down field, which uses dynamic values.
Is it possible to adjust the high of the drop down field depending on the amount of values?
Kind regards
Astrid
GreyHead 29 Sep, 2015
Hi Astrid,

You need to change the size attribute I think - you might be able to do that with JavaScript.

Bob
dimna 29 Sep, 2015
Hi Bob,

thank you for your quick reply.
I know it, I have to learn more JavaScript :-)

But perhpaps anyone can give me an lInk to an example where I can start ...

Regards
Astrid
GreyHead 29 Sep, 2015
Hi Astrid,

This seems to work
jQuery(document).ready(function(jQ){
  jQ('#dropdown1').on('change', delayUpdate);

  function delayUpdate() {
    setTimeout(changeSize, 50);
  }
  function changeSize() {
    var size = jQ('#dropdown2').children('option').length;
    jQ('#dropdown2').prop('size', size);
  }
});

The two drop-downs have ids dropdown1 and dropdown2. There is a little extra code to delay the change until ChronoForms has assigned the new options. You can see this working here

Bob
This topic is locked and no more replies can be posted.