Setting a field value for a dropdown
- This topic has 2 replies, 2 voices, and was last updated 6 years, 4 months ago by .
Viewing 2 reply threads
Viewing 2 reply threads
- You must be logged in to reply to this topic.
Home › Forums › General discussion › Setting a field value for a dropdown
Hi Alexander
I’m struggling to set the field value of a drop-down field called SlotLength
function dffs_PreSaveDuration(){
var noBaby = getFieldValue("BabyNumber").split(" ", 1);
var X40 = Math.floor(noBaby*40);
console.log(X40);
setFieldValue("SlotLength", "[X40]");
The BabyNumber field is a drop-down with the following values: 1 baby, 2 babies, 3 or more babies. The SlotLength field is also a drop-down with the following values: 40, 80, 120. When checking the console.log(X40) it shows the expected value. I’m clearly making a mistake setting the field value for SlotLength. But I cannot figure it out.
Regards
Paul
Hi Alexander,
I’ve just realised I needed to change the number to string:
function dffs_PreSaveDuration(){
var noBaby = getFieldValue("BabyNumber").split(" ", 1);
var X40 = Math.floor(noBaby*40).toString();
console.log(X40);
setFieldValue("SlotLength", X40);
}
So all sorted. Thanks anyway!
Paul
I’m glad you figured it out, but it wasn’t a problem with the numeric value. You didn’t pass the actual variable, but a string “[X40]” to the function.
Alexander