You are viewing limited content. For full access, please sign in.

Question

Question

Copy Checkbox Field and Address Field values

asked on July 15, 2016

Hi there,

 

May I request for a sample JavaScript to copy the values of one Checkbox (the checks) and Address Field to another Checkbox and Address Field that's on the same form?

 

Any example or similar will be very useful and much appreciated. Thank you.

0 0

Answer

SELECTED ANSWER
replied on July 15, 2016

Marlon,

For the checkboxes you could use this javascript.  It's a little tedious, I'm sure someone could probably give you a function that could do all of them in one block, but in case you need it fast this would definitely work.  Just have to change a few things....number one, you have to see what the values are in your checkbox fields below the options themselves in the edit field.  This is here:

 

You will see those listed in the script as the comparisons I am making to the "choice" variable.  After that, just change the class name in the advanced tab of the first checkbox field to CheckBoxField1 and the second to CheckBoxField2.  Then this should work.  The result is here:

 

And here is the code:

$(document).ready(function () {
       
    
    $('#Field1-0').change(function(){   
    var choice = $('.CheckBoxField1 input:checked').val();
    if (choice == 'V_1'){
        $('#Field3-0').prop("checked", "true");
    } 
      else  {
        $('#Field3-0').prop("checked", false);
      }
        });  
       $('#Field1-1').change(function(){   
    var choice = $('.CheckBoxField1 input:checked').val();
    if (choice == 'V_3'){
        $('#Field3-1').prop("checked", "true");
    } 
      else  {
        $('#Field3-1').prop("checked", false);
      }
        });  
      
        $('#Field1-2').change(function(){   
    var choice = $('.CheckBoxField1 input:checked').val();
    if (choice == 'V_4'){
        $('#Field3-2').prop("checked", "true");
    } 
      else  {
        $('#Field3-2').prop("checked", false);
      }
        });  
           
     $('#Field1-3').change(function(){   
    var choice = $('.CheckBoxField1 input:checked').val();
    if (choice == 'V_4_1'){
        $('#Field3-3').prop("checked", "true");
    } 
      else  {
        $('#Field3-3').prop("checked", false);
      }
        });  
              
});

 

1 0

Replies

replied on July 19, 2016

Hi Rick,

 

Thank you very much for this, did a couple of edits and it worked perfectly.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.