Skip to main content

Search

Get next value of choice field

Comments

5 comments

  • skybow Support

    Please try this Calculated expression:

    var valueToSelect = "";
    var selected = [[YourChoiceFieldName]];
    var inputs = jQuery("input[id^='YourChoiceFieldName']");
    var selectedIndex = 0;
    inputs.each(function(i, e){
      var optionValue = jQuery(e).val();
      if(optionValue === selected){
        selectedIndex = i;
      }
    });
    var nextElement = inputs[selectedIndex +1];
    if(nextElement){
      return jQuery(nextElement).val();
    }else{
      return selected;
    }

    Do not forget to change field name used in the script.

    0
  • Senad

    Hello,

     

    thank you for your answer.

     

    The expressions is returning a value, but its always the same value as chosen. 

     

    Problems that I've noticed:

    var optionValue does not loop, selectedIndex stays always 0 like its defined.

    var nextElement stays undefined and the last part else{return selected;} is always triggering.

    0
  • skybow Support

    Please make sure that you define correct id:

    0
  • Senad

    Great, its working now, the problem was in the script above, this line:

     

    var inputs = jQuery("input[id^='YourChoiceFieldName]']");

     

    I was double clicking the names so the bracket left there.

     

    Thank you, great solutions.

    0
  • skybow Support

    Thank you! Please feel free to contact us in case of further difficulties.

    0

Please sign in to leave a comment.