Forum


Calc Builder Support

Calc Builder support
Forums
Public write access is disabled. Please login

Use variables as up and down limits. 20.08.2014 18:27

How can I use variables as up limit, down limit and defaut value into number input?
Thanks.

Re: Use variables as up and down limits. 21.08.2014 13:35

Hi,
not sure if we fully understand your question, sorry. Where do you have available the variables you need to use? They should be recovered from other inputs of the form? Then maybe we could share with you any js code to modify the validators on fly.

Thanks, regards
Moonsoft Team
www.moonsoft.es

Re: Use variables as up and down limits. 21.08.2014 16:29

Yes.
I want use other number input as up and down limits of a number input.
Is it possible?

Re: Use variables as up and down limits. 21.08.2014 17:25

Yes, then you need to add the proper javascript to your calculator. You will need these functions:


To set maximum or minimum values to a field named 'yourfieldname':

CB( "input[fldname=yourfieldname]" ).rules( "add", {max: 3});

and/or

CB( "input[fldname=yourfieldname]" ).rules( "add", {min: 1});


You only need to replace the name of the field, and maximum or minimum values.

In order to recover a value from another input

var value=CB( "input[fldname=yourfieldname]" ).val();


To remove previos rules added :


CB( "input[fldname=yourfieldname]" ).rules( "remove", "max" );
CB( "input[fldname=yourfieldname]" ).rules( "remove", "min" );



You surely want to change this values when another field changes, so the full function should look like:

CB( "input[fldname=yourotherfieldname]" ).change(function(){



CB( "input[fldname=yourfieldname]" ).rules( "remove", "max" );
CB( "input[fldname=yourfieldname]" ).rules( "remove", "min" );
var value=CB( "input[fldname=yourotherfieldname]" ).val();
CB( "input[fldname=yourfieldname]" ).rules( "add", {max: value});

});


Hope this helps, regards
Moonsoft Team
www.moonsoft.es

Re: Use variables as up and down limits. 22.08.2014 17:35

Can I use php variables (used in "Code") as down limit or default value?
Thanks.

Re: Use variables as up and down limits. 23.08.2014 12:11

Hello,

No, because PHP code is executed after the form is validated and submited.

Regards,
Moonsoft Team
www.moonsoft.es
Are you satisfied with our products/services/support?
Please help us to keep improving, add a review at  joomla extensions site and  magento connect

Our clients' feedback