You are viewing limited content. For full access, please sign in.

Question

Question

Calculating the number of times an option is selected in a form

asked on September 25, 2014

I am trying to create a form that counts the number of times a particular option is selected in a form and use it in another field. 

For example, if a user selects pending in five fields, i would like another field that would say "Total Number of Pending Requests 5"

How can i do this? 

0 0

Replies

replied on September 25, 2014 Show version history

Can you tell me more about this form? Is this "Pending" field a drop-down? Does it appear in a table? Would you get this information from a lookup rule?

Here's a sample to help you get started. Add the request CSS class to the field where the "Request Pending" value is. If you're using a checkbox, note that Forms will replace spaces with underscores in these values.

Add the total CSS class to the field where you want the number of pending requests to appear.

$(document).ready(function() {
    $(document).on('change','.request select, .request input', tallyRequests)
  
    function tallyRequests() {
        $('.total input').val(($('.request option[value="Request Pending"]:checked').length) + $('.request input[value="Request_Pending"]:checked').length); 
    }
});

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.