TOPIC:

BF : count form records, Element value (based on Value) 1 year 2 months ago #238256

  • Topic Author
  • Gilles361
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 248
  • Thanks: 6
Hi,
I've a form (FORMNAME), Element > radio button CHOICE (value = X, Y or Z) (value = text or number)

Once I'm starting my form, I would like to count the number of time I've CHOICE with value X, value Y and value Z. Then I will perform action based on these values...

This could be done using different Hidden elements:
Element ChoiceX could count CHOICE value X, ...

What method would you recommend to do so?
PHP command line or Javascript init action or ...

Thanks, Gil

Please Log in or Create an account to join the conversation.

BF : count form records, Element value (based on Value) 1 year 2 months ago #238270

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 579
  • Karma: 4
  • Thanks: 97
Bonjour Gilles.

La méthode pour compter le nombre d'enregistrements d'une valeur à déjà été donnée de nombreuses fois sur ce forum.
Une petite recherche avec le mot "count" devrait te donner des résultats.
Il reste à adapter à ta situation.

Cordialement.

Hello Gilles.

The method for counting the number of records of a value has already been given many times on this forum.
A little search with the word "count" should give you results.
It remains to adapt to your situation.

Best regards.

Please Log in or Create an account to join the conversation.

BF : count form records, Element value (based on Value) 1 year 2 months ago #238271

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
Hello,

If I've understood correctly, your form has multiple radio buttons with possible choices X,Y or Z and you wish to count the number for example how many times the X was selected as the answer.

You can do that using JavaScript. You can put the code in Actionscript of each radio group that is included in counting or you can write Initialization script like follows.

Go to form's Advanced properties > More options > Scripts and in Initialization script set Type to Custom and put there the following code:
function ff_FORMNAME_init()
{
setInterval('calc()', 500);
} // ff_FORMNAME_init

function calc() {

var sumX = 0;
var sumY = 0;
var sumZ = 0;

if(jQuery('[name="ff_nm_radiogroup1name[]"]:checked').val() == "X") {
	sumX = Number(sumX) + 1;
} 
else if(jQuery('[name="ff_nm_radiogroup1name[]"]:checked').val() == "Y") {
	sumX = Number(sumY) + 1;
} 
else if(jQuery('[name="ff_nm_radiogroup1name[]"]:checked').val() == "Z") {
	sumX = Number(sumZ) + 1;
} 


if(jQuery('[name="ff_nm_radiogroup2name[]"]:checked').val() == "X") {
	sumX = Number(sumX) + 1;
} 
else if(jQuery('[name="ff_nm_radiogroup2name[]"]:checked').val() == "Y") {
	sumX = Number(sumY) + 1;
} 
else if(jQuery('[name="ff_nm_radiogroup2name[]"]:checked').val() == "Z") {
	sumX = Number(sumZ) + 1;
} 

ff_getElementByName('ChoiceX').value = sumX;
ff_getElementByName('ChoiceY').value = sumY;
ff_getElementByName('ChoiceZ').value = sumZ;

}
NOTE: In the code above replace FORMNAME with the actual name of your form.
Also, replace radiogroup1name and radiogroup2name with the actual names of elemetns in your form.

Let me know whether you have managed to set this for your form and whether it is working as you wanted.

Regards,

Mihaela

Please Log in or Create an account to join the conversation.

BF : count form records, Element value (based on Value) 1 year 2 months ago #238272

  • Eddy.vh's Avatar
  • Eddy.vh
  • Offline
  • Ultimate Breezer
  • Ultimate Breezer
  • Posts: 579
  • Karma: 4
  • Thanks: 97
Peut-être ai-je mal compris la question mais je pense que tu cherches à charger le nombre d'enregistrements de ces valeurs déjà stockées depuis la base de données.

Est-ce bien ça ?


Maybe I misunderstood the question but I think you're trying to load the number of records of these values ​​already stored from the database.

Is that it?

Please Log in or Create an account to join the conversation.

BF : count form records, Element value (based on Value) 1 year 2 months ago #238284

  • Topic Author
  • Gilles361
  • Offline
  • Expert Breezer
  • Expert Breezer
  • Posts: 248
  • Thanks: 6
Hi Eddy,
yes, that is correct. Only number of Element records is enough.
If count is over a "Limit" value, I will go to Form closed page.

Solution 1 : In my BF form, I've two Elements : "element-1" and "Element-2"
Both have different count limits, so I need to count each number of "element-1" and "Element-2" record values and not only Form

Solution 2 : In my BF form, I've an "Element-1" with two values "value-1" or "value-2". Both VALUES have different count limits, so I need to count each number of records with "value-1" and "value-2".
If Value-1 = Limit-1 go to For closed Page
If Value-2 = Limit-2 go to For closed Page

Thanks, Gil

Please Log in or Create an account to join the conversation.

BF : count form records, Element value (based on Value) 1 year 2 months ago #238292

  • mihaela
  • Offline
  • Developer
  • Developer
  • Posts: 3128
  • Karma: 105
  • Thanks: 415
Hello,

Ok, I see I have misunderstood your request before.

You can do this using PHP.
Go to your form's Advanced properties > More options > Form pieces and in Before Form pieces you can write a query to count the wanted value.

You can write code similar to this:
$db = JFactory::getDBO();
$db-> setQuery("Select count(id) From #__facileforms_subrecords Where value= WANTEDVALUE and name=ELEMENTNAME");
if( $db->loadResult() > 100 )
{
     // replace index.php with the url that you wish to recirect to
     header("Location: index.php");
     exit;
}

What this will do is it will redirect or stay at the form based on the query result.

Let me know whetehr this is working as you wanted.

Regards,

Mihaela

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
  • 2
Moderators: ForumSupport
Time to create page: 0.046 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!