The documentation for the droplist is here:
https://dev.vantiq.com/docs/system/cbref/index.html#droplist
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();
http.setVantiqUrlForSystemResource("topics");
http.setVantiqHeaders();
var dL = client.getWidget("Droplist1");
var theMessageObject = dL.boundValue;
var topicName = "/POCBoo/eventStream";
http.publish(theMessageObject,topicName,function(response)
{
// "response" is meaningless for a "publish"
},
function(errors)
{
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 page.data properties, it will automatically be updated. You can do the following:
– Create a data object. For example: page.data.dlDataValue (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 = page.data.dlDataValue;
- You must be logged in to reply to this topic.
Very simple: I have a dropdown list.
onChange: want to send the selected value somewhere.
HOW?
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();
http.setVantiqUrlForSystemResource(“topics”);
http.setVantiqHeaders();
http.publish(result,”/POCBoo/eventStream”,function(response)
{ …