Jump to content
  • 0

Rules For Fields Based On Prior Selection



Hi, I have two fields that I am trying to make a conditional rule with but am not able to within the rules of Caspio.



I have two lookup table I am using for drop down box options and I would like to conditionalize the options available - or the default selection - of drop down B based on the selection in drop down A.



I have drop down A - provider types:


10 - Main SFA

12 - Sub SFA

30 - Athletics

40 - Departments

397 - Campus Card


I have drop down box B - invoice types:


1 - By Date

2 - By Total

3 - POS Detail

4 - Page Break

5 - Multipage

6 - By CUstomer

7 - Total Only



So, if the submittor selects "30 - Athletics" as their provider type I would like the default option for invoice type to be "3 - POS Detail" but they still have the option to change if necessary.



I am not sure if this is possible but any help would be appreciated.

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Hello Liz,


You can try the following JavaScript code:

function select_default()
    var first_dropdown = document.getElementById("InsertRecordAdropdown");
    var selection = first_dropdown.options[first_dropdown.selectedIndex].value;
    var second_selection = "";
    if (selection==1) second_selection = 3;
    if (selection==2) second_selection = 5;
    if (selection==3) second_selection = 7;
    var second_dropdown = document.getElementById("InsertRecordBdropdown");
    for (var i = 0; i < second_dropdown.options.length; i++ ) 
        if (second_dropdown.options[i].value == second_selection)
                second_dropdown.options[i].selected = true;


Please, insert names of yours drop-down lists instead of Adropdown and Bdropdown.

Usually, values of drop-down lists are numbers, so I have used numbers.

You can use words, for example:


if (selection=="30 - Athletics") second_selection = "3 - POS Detail";


and so on.


I hope, it helps.

Please feel free to ask, if the code is not clear.

Link to comment
Share on other sites

  • 0

Hi Jan,


Thank you so much for helping!

Would I put this in the header or footer of my data page? Does it matter?


Also, will a comma have an effect on this portion in red:


if (selection=="30 - Athletics") second_selection = "V1 - Sort By Date, Item Detail";

Link to comment
Share on other sites

  • 0

Hi Liz,


Please enter the code to the Footer element.

If the code is entered to the Header element, it can do not work.


As far as I know, a comma should not have an effect.


Please make sure, that Display and Value in your drop-down lists are the same.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...