Skip to main content
Nintex Community Menu Bar
Solved

Radio Button List (get count)

  • July 25, 2017
  • 6 replies
  • 53 views
  • Translate

Forum|alt.badge.img+8

Hi All

 

I have a Radio Button List control on a smartform which is being populated by a SmartObject

I'd like to get a count of the number of items populated in the control when it's populated 

 

Have tried using a the list count function and others but cant find a way to achieve it.

 

Anybody have a solution?

 

thanks
Paul

Best answer by Albarghouthy

Hi Paul,


 


Maybe this script can help, transfer it to a data label after populating the radio button list


 


 


<script type="text/javascript">
var count = $(".stack-container label").length;
$("[name='dlCount']").SFCLabel('option', 'text', count);
</script>

 


Check 'Literal' property for the data label 


Add another data label to set the count value, in my script I am setting the value to data label called dlCount.


 


You can also write stored procedure to return the count if your data source is SQL.


If you have more than one radio button list control on your form/view, the above script will not return the correct count


 


you can use this for specific Radio button list control:


 


var count = $( "div[id$='MultiSelectPanel']").eq(0).find('label').length;

** eq(0) is used to select element at index n.


 


hope that helps


 


 

View original
Did this topic help you find an answer to your question?

6 replies

Albarghouthy
Forum|alt.badge.img+16
  • Scholar
  • 741 replies
  • Answer
  • July 25, 2017

Hi Paul,


 


Maybe this script can help, transfer it to a data label after populating the radio button list


 


 


<script type="text/javascript">
var count = $(".stack-container label").length;
$("[name='dlCount']").SFCLabel('option', 'text', count);
</script>

 


Check 'Literal' property for the data label 


Add another data label to set the count value, in my script I am setting the value to data label called dlCount.


 


You can also write stored procedure to return the count if your data source is SQL.


If you have more than one radio button list control on your form/view, the above script will not return the correct count


 


you can use this for specific Radio button list control:


 


var count = $( "div[id$='MultiSelectPanel']").eq(0).find('label').length;

** eq(0) is used to select element at index n.


 


hope that helps


 


 

Translate

Forum|alt.badge.img+8
  • Author
  • 35 replies
  • July 25, 2017

Hi Mustafa

This nearly works for me - but I found one small issue
I'm filtering the radio button list data based on a text value I pass to the control


this works OK:-
1. Input string into text box
2. Return matched results into radio button list
3. transfer your script to data label and get count

However if I enter a new value into the text box and rerun script the previous count is retained even if the number of results are different
Seems the initial value is always kept

Is there someway I can reset when I run again?

 

Paul

Translate

Albarghouthy
Forum|alt.badge.img+16

Hi Paul,


 


Clear the data label that contains the script after transferring it.


 


So you will need two transfer actions


 


1- transfer script to data label.


2- clear data label.

Translate

Forum|alt.badge.img+8
  • Author
  • 35 replies
  • July 25, 2017

Great - that works - thanks again

Translate

Forum|alt.badge.img+7
  • 136 replies
  • November 10, 2017

I have been trying to do this but I must be missing something. I am using a chocie control with check boxes if that makes any difference. Here is what I did.

 

I create a rule on the choice list called 'What BU or Groups will use Choice' , on changed

Used a data transfer to copy this script into a data label control called "bucountData Label1".

 

<script type="text/javascript">
 var count = $( "div[id$='What BU or Groups will use Choice']").eq(0).find('label').length;
  $("[name='ScoreData LabelGroups']").SFCLabel('option', 'text', count);
</script>

 

All I get in 'ScoreData LabelGroups' is a zero.

 

What did I do wrong? Any help appreciated

 

 

Translate

Albarghouthy
Forum|alt.badge.img+16
  • Scholar
  • 741 replies
  • November 14, 2017

Hi 


 


Modify the selector to name instead of id:


 


<script type="text/javascript">
var count = $( "div[name$='What BU or Groups will use Choice']").eq(0).find('label').length;
$("[name='ScoreData LabelGroups']").SFCLabel('option', 'text', count);
</script>

hope that helps

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie Settings