How do you access a droplist value from JavaScript?

Very simple: I have a dropdown list.
onChange: want to send the selected value somewhere.


Here’s my current code. I’ve tried many different combinations of VAIL. Does someone have working code?

var dL = client.getWidget(“Droplist1”);

var result = dL.options[dL.selectedIndex].value;
var http = new Http();

{ …


Posted: June 18, 2020 at 5:39 pm
Replies: 1
Jun 18, 2020
Posted by Ken

The documentation for the droplist is here:

There are two common solutions to this question. The first solution uses the “boundValue” property of the droplist. Your complete onChange event code might look like this:

var http = new Http();

var dL = client.getWidget("Droplist1");
var theMessageObject = dL.boundValue;

var topicName = "/POCBoo/eventStream";

    // "response" is meaningless for a "publish"
    client.showHttpErrors(errors,"Doing a publish on a topic");

The second solution makes use of the “Data Binding” property of the droplist. If you set the DataBinding value for the droplist to a variable in the properties, it will automatically be updated. You can do the following:

– Create a data object. For example: (integer)
– Set the “Data >> DataBinding” property of the droplist to the data object
– Replace the two “dL” lines of code in the example above with the following:

var theMessageObject =;

  • This reply was modified 4 years ago by Ken.
  • This reply was modified 4 years ago by Ken.
  • This reply was modified 4 years ago by Ken.
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
© Vantiq 2024 All rights reserved  •  Vantiq Corporation’s Privacy Policy and Cookie Policy