Moonsoft Software Solutions

Set default value

Started 3 Sep 2014 · 3 replies

  1. moon_1760
    How can I set default value into number input using another number input?
    Thanks.
  2. Moonsoft support
    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").change(function(){

    var newvalue=CB("input").val();

    CB("input").val(newvalue);

    });

    Hope this helps, regards
  3. Moonsoft support
    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.
  4. Moonsoft support
    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").change(function(){

    setTimeout(function(){
    var newvalue=CB("div").html();

    CB("input").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

Still stuck?

Customers with an active license can open a support ticket.

Log in to open a ticket