Closed (duplicate)
Project:
Webform
Version:
5.x-2.1.3
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 May 2008 at 15:30 UTC
Updated:
11 Aug 2011 at 08:24 UTC
I'd love to be able to create a webform to poll users of amounts they spend at an event and have webform automatically calculate averages AND totals spend from each field on the webform.
I don't even see there is an option for an integer field...just a 'textfield' which people could enter text...or the $ sign which would mess up the output. I thought it'd be much like the cck fields where you could create an integer field and set a prefix (the $ sign).
Is this possible?
Comments
Comment #1
quicksketchYou've been able to create a prefix on fields since 2.1. Webform however has no support for type-cast fields (like integer, text, decimal, etc). Since this is such an old request, I'm going to go ahead and close. Please reopen if you have further questions on this subject.
Comment #2
mdowsett commentedI've moved it to a 'feature request' as I'd like to see if there is any interest in making that a reality. And it was my mistake that I had it flagged as a d6 issue.
Does anyone else want auto-calculated stats from submitted webform fields? It seems to me it'd be a handy stat to have.
Comment #3
quicksketchI don't think Webform has an existing paradigm for solving this problem. Could you be more descriptive in how you imagine this working? Some problems that will need to be solved: How would webform know what fields it should tally up? Would numeric values have to be enforced in certain fields?
Comment #4
mdowsett commented>How would webform know what fields it should tally up?
>Would numeric values have to be enforced in certain fields?
sure....set a webform field as:
- integer - for straight numbers (no calculation)
- sum - for integers that would be added in the webform results
- average - for integers that would averaged from all submissions in the webform results
In theory, it sounds simple to me...but I am no programmer! :)
Comment #5
mandclu commentedOne approach I took to solving this problem was to create a new field type, called "number". You can download the code I've been using here:
http://drupal.org/node/260708
For the record, it allows you to specify whether the field should accept an integer or a float (decimal), and whether the analysis page should show an average or a sum.
Give it a whirl, it sounds like it should do what you need.
Comment #6
mandclu commentedSorry, didn't mean to change the title of the thread.
Comment #7
quicksketch#260708: Number component (Numeric field)
Comment #8
j3rry commenteduse the module http://drupal.org/project/webform_validation
and use regex.