• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: once more: simple calculation

once more: simple calculation 14 years 4 weeks ago #10253

  • fbrune
  • fbrune's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
I use the "simple calculation" with radio buttons with this code:
<script type="text/javascript"> 
function calculate() 
{ 
    var op1=document.getElementsByName('form[radio1]'); 
    var op2=document.getElementsByName('form[radio2]'); 
    var result=document.getElementById('result'); 
    result.value=0; 
    result.value=parseInt(result.value); 
    for(i=0;i<op1.length;i++) 
        if(op1[i].checked) result.value=parseInt(result.value)+parseInt(op1[i].value); 
    for(i=0;i<op2.length;i++) 
        if(op2[i].checked) result.value=parseInt(result.value)+parseInt(op2[i].value); 
 
    return false; 
} 
</script>  

Now i want a quantity supplement between radio1 and radio2, maybe with a numeric textbox, so that the multiplication takes only efekt to the radio1 value. {(radio1 * quantity)+ radio2}

Can someone help me how i must change the code?

Thx.
Last Edit: 14 years 4 weeks ago by fbrune.
The administrator has disabled public write access.

Re:once more: simple calculation 14 years 3 weeks ago #10275

  • andreic
  • andreic's Avatar
  • OFFLINE
  • RSJoomla! Official Staff
  • Posts: 722
  • Thank you received: 59
Hello,

You could try setting the quantity field to be required and modifying this line of your script:
if(op1[i].checked) result.value=parseInt(result.value)+parseInt(op1[i].value); 
 
if(op1[i].checked) result.value=parseInt(result.value)+(parseInt(op1[i].value)*parseInt(quantity_field).value); 
Also you should trigger this script when filling in the quantity field as well by adding this line in the "Additional attributes" property of your quantity field:
onkeyup="calculate();"
Please note: my help is not official customer support. To receive your support, submit a ticket by clicking here
Regards,
RSJoomla! Development Team
Last Edit: 14 years 3 weeks ago by andreic.
The administrator has disabled public write access.

Re:once more: simple calculation 14 years 3 weeks ago #10279

  • fbrune
  • fbrune's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 3
it works fine for me

many thx
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!