The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group

Slack Signup
Newsletter Optin
Help Desk

Change field count to a value

Labels

This Discussion is public

Notifications

I am need of a bit of help if there is someone who has a minute. I don't think this is complex, however it is beyond me.

I am counting the number of checkboxes checked in a form with this script:

<script type="text/javascript">
jQuery(document).ready(function($){
$('input[name="item_meta[214][]"]').change(function(){
var val1 = $("input[name='item_meta[214][]']:checked").length;
$("#field_f7i9x").val(val1);
$("#field_f7i9x").change();
});
});
</script>

What I am looking to get done is the following:

If value is 1 or 2, display 1x
If value is 3, 4, or 5, display 3x
If value is 6 display 6x.

Any help or guidance will be greatly appreciate. Thanks in advance.

I currently have a hidden field doing the count and the max will be 6 and the minimum will be 1. This is for a magazine advertising table and the 1x, 3x, and 6x are for a rate table. I will be using the 1x, 3x, and 6x values to do a lookup to grab the correct rate.

Here is an example you will have to fit to suit your need: https://jsfiddle.net/kxrTS/367/

Discussion closed.