• 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: function calculateText, modified

function calculateText, modified 12 years 6 months ago #15449

Hi my name is Nick,
I have one question.
This example is ok, but i would like that the customers must be forced to use 50 and its multiply (EXAMPLE ONLY:50/100/150/200/250...):

function calculateText(){
var op1=document.getElementById('field1');
var op2=document.getElementById('field2');
var result=document.getElementById('Total');
if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;
result.value=0;
result.value=parseInt(result.value);
result.value=parseInt(result.value)+parseInt(op1.value)+parseInt(op2.value);}

and the total must be a part of the set of price

(EXAMPLE: from 50 to 300 the price is 1$
from 350 to 600 the price is 0,50 cent
from 650 to 1200 the price is 0,40 cent
and so on…)

Is it possible?

Thank you for your help!

Nick B)
The administrator has disabled public write access.

Re: function calculateText, modified 12 years 5 months ago #15463

I have risolved the problem.
this is the code:

if(op1.value=="" || op1.value!=parseFloat(op1.value) || op1.value%50!=0) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value) || op2.value%50!=0) op2.value=0;

instead of:

if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;

And in order to show the corresponding price in the Total field instead of the total of the calculation you will have to use a code line similar to the following one(with additional verifications for the rest of the values):

if(result.value>50 && result.value<300) result.value=1;

after the code line:

result.value=parseInt(result.value)+parseInt(op1.value)+parseInt(op2.value);

----
Thank's to technical support.

But I have another question.
Can I visualize the final price in every update windows?

EXAMPLE CODE:

<script type="text/javascript">
function calculateText()
{
var op1=document.getElementById('field1');
var op2=document.getElementById('field2');
var result=document.getElementById('Total');

if(op1.value=="" || op1.value!=parseFloat(op1.value)) op1.value=0;
if(op2.value=="" || op2.value!=parseFloat(op2.value)) op2.value=0;

result.value=0;
result.value=parseInt(result.value);
result.value=parseInt(result.value)+parseInt(op1.value)+parseInt(op2.value);
}
</script>
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!