isSelected

Reading Time: 1 minute

Checks if the given value in the field is selected or not.

Description

vcc.isSelected(field: string, [value: string], [key: string]): bool

Parameters

field
The name of the field.

value
The value you want to look for.

key
The name of the value property (DEFAULT: valueid).

Return values

bool

If the value parameter is missing, it returns true if:

  • text field – the field is not empty
  • simple field – there is a selected value
  • multiple field – there are selected values

If the the value parameter exists, it returns true if:

  • text field – the value of the field is exatly the same as the given value (the 3rd parameter is unused in this case)
  • simple field – there is a selected element and it’s property defined by the key is exactly the same as the given value.
  • multiple field – there are selected values whose properties defined by the key are exactly the same as the given value.

Example

$('page1').onNext = function() {
     // text field
     dump(vcc.isSelected('haircolor_text', 'brown'));

     // simple field, the description of the selected value is 'budapest'
     dump(vcc.isSelected('hometown_radio', 'budapest', 'description'));

     // multiple field, there is a selected value which export_value is 'MTV'
     dump(vcc.isSelected('tvchanels_checkbox', 'MTV', 'export_value'));
};

There are no comments yet.
Subscribe to our newsletter
or Contact us!
Please note that by subscribing to our newsletter, you agree to receive regular email messages from VCC Live® about service related news and updates. By subscribing to our newsletter, you also agree that VCC Live® will use your data in accordance with the applicable Privacy Policy until you unsubscribe from the newsletter.