select option value
Hello!!!
I have a question, is there anyway to make trough javascript put a value on a select widget.
Example
my select widget have loaded 3 items
p1
p2
p3
and i want when the form start that the widget start with the value p1, but if i change another field the select take a value that is needed.
is that posible???
my select is on a $item.
i have tried to make this
$data.forminput.variableinput.items[1].provider.id=1;
but when i try that the system tell me that is undefined...
so what can i do???
1 answer
Hello,
You'll need to use something like a javascript expression to change the value of the variable used in the dropdown select. You could use a switch statement. For example:
var dropdownValue
switch ($data.value) {
case ("selection1") :
dropdownValue = "p1";
break;
case ("selection2") :
dropdownValue = "p2";
break;
default :
dropdownValue = "p3";
}
return dropdownValue;