1. alextunas
  2. General
  3. Sunday, February 09 2014, 09:29 PM
You can add a field whose value is calculated from other. For example:
I have 5 radio type fields (Yes or No): the Si are 1 and not 0.

Another field that will sum the values ​​of these 5 fields. Based on this value, if it is between 0 and 2 may have a low level, if it is between 3 and 4 have a medium level and if 5 will have a high level.
This is possible??
How?
admin Accepted Answer
Admin
Hi,
yes it's possible but not simple.

You need to write a plugin to do this, or you can with javascript (less secure).
  1. more than a month ago
  2. General
  3. # 1
alextunas Accepted Answer
To do this using javascript, you could show an example?
or
You can use a global variable and go validating each radio button?
Thanks
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
To do this using javascript, you could show an example?

- create a hidden field for store the sum of yours radio fields
- added this example code to your template
jQuery(document).ready(function($)
{
$('#member-registration,#member-profile').submit(function(){
var tot=0;
if($("[name ='jform[alias_of_radio_btn1]']:checked").length) tot+=parseInt($("[name ='jform[alias_of_radio_btn1]']:checked").val());
if($("[name ='jform[alias_of_radio_btn2]']:checked").length) tot+=parseInt($("[name ='jform[alias_of_radio_btn2]']:checked").val());
if($("[name ='jform[alias_of_radio_btn3]']:checked").length) tot+=parseInt($("[name ='jform[alias_of_radio_btn3]']:checked").val());
$("[name ='jform[alias_of_hidden_field]']").val(tot);
});
});
  1. more than a month ago
  2. General
  3. # 3
alextunas Accepted Answer
I have already done this, but as I can know if it works well, if you take the correct value?
I've put a alert (val) in the function, but not displayed. I have done something wrong?
  1. more than a month ago
  2. General
  3. # 4
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.
Sorry, the discussion is currently locked. You will not be able to post a reply at the moment.