Skip to content Skip to footer

Form script to automatically select choices

Description:

Form script to change choice depending on other choice list values. In the below-form script, we have taken two choice lists “Frequency type” and “Frequency type 2” where values contain (Monthly, quarterly, half-yearly, yearly) and (month, day, year) respectively.
If the user selects “monthly” from the first choice list, the other choice list should return as “Month”.

function onValueChange(ws)
{
  var v1= ws.getWidgetValue("Type");
          ws.setWidgetValue("Type_2",v1);
          ws.reloadUICell("Type_2");
  
  
}
 
function onValueChangeFrequency(ws)
{
  var val = JSON.parse(ws.getWidgetValue("Frequency_Type"));
  
  if(val == "Monthly")
  {
    ws.setWidgetValue("Frequency_Type_2",'[\"Month\"]');
    ws.setWidgetValue("Frequency",'1');
    ws.reloadUICell(["Frequency_Type_2"]);
    ws.reloadUICell(["Frequency"]);
  }
  else if(val == "Quarterly")
  {
    ws.setWidgetValue("Frequency_Type_2",'[\"Month\"]');
    ws.setWidgetValue("Frequency",'3');
    ws.reloadUICell(["Frequency_Type_2"]);
    ws.reloadUICell(["Frequency"]);
  }
  else if(val == "Half Yearly")
  {
    ws.setWidgetValue("Frequency_Type_2",'[\"Month\"]');
    ws.setWidgetValue("Frequency",'6');
    ws.reloadUICell(["Frequency_Type_2"]);
    ws.reloadUICell(["Frequency"]);
  }
  else if(val == "Yearly")
  {
    ws.setWidgetValue("Frequency_Type_2",'[\"Year\"]');
    ws.setWidgetValue("Frequency",'1');
    ws.reloadUICell(["Frequency_Type_2"]);
    ws.reloadUICell(["Frequency"]);
  }
  else
  {
    ws.setWidgetValue("Frequency_Type_2",val);
    ws.reloadUICell(["Frequency_Type_2"]);
  }
}
  

Was This Article Helpful?

0
0 Comments

There are no comments yet

Leave a comment

Your email address will not be published. Required fields are marked *

Close Bitnami banner
Bitnami