Forum


Calc Builder Support

Calc Builder support
Forums
No se permite escribir sin estar logado. Por favor, login

Set default value 03.09.2014 20:26

How can I set default value into number input using another number input?
Thanks.

Re: Set default value 03.09.2014 20:34

Hi,
in order to set field values dynamically you must use javascript section to capture the event of the first field changing and assign a new value to the destination field, this code should be placed at the first js tab of your calculator, replacing yourfirstfieldname and yoursecondfieldname with the right field names at your form:

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

var newvalue=CB("input[fldname=yourfirstfieldname]").val();

CB("input[fldname=yoursecondfieldname]").val(newvalue);

});

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

Re: Set default value 16.11.2015 18:16

hi i want the same as above but from an inline field to a text field default value that can be changed by the user.

Re: Set default value 17.11.2015 10:52

Hi,
that is more complex, as you can't capture the event of the inline result being changed, because it's done internally by the calculator script. As a workaround, you can use other field change event, wait sometime until the inline field has the new value and then use it. The structure would be:


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

setTimeout(function(){
var newvalue=CB("div[fldname=yourinlinefieldname]").html();

CB("input[fldname=yoursecondfieldname]").val(newvalue);

}, 3000);

});


replacing

yourfirstfieldname
yourinlinefieldname
yoursecondfieldname

with your calculator fields. You can create more sections with the same structure and other 'yourfirstfieldname' in order to attach it to more input fields.


This is not an optimal solution as you're waiting 3sg for the result, you must ensure this is enough for the calculator returning the proper value to the inline, you should increase this time if required.


Hope this helps, regards

Edited by MSTeam - 18.11.2015 18:54
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

Lo que nuestros clientes opinan de nosotros