Expand my Community achievements bar.

Announcing the launch of new sub-community for Campaign Web UI to cater specifically to the needs of Campaign Web UI users!

How to get mirror values from one field to another when checkbox is checked in webpage

Avatar

Level 4

Hi All,

We are trying to get mirror value from one field to another when a checkbox is checked.

While trying we are getting issues as mentioned below.

1. when checkbox is checked and webpage is submitted, the 2nd field (the field in which the values came as mirror from 1st field) is showing validation/mandatory issue.

2. If we just select the 2nd field in webpage after checking the checkbox and the mirror values is taken in to 2nd field the validation/mandatory issue is not coming and able to submit the form.

 

Can someone please help resolve this issue ASAP?

 

Thanks & Regards,

Greeshma

@_Manoj_Kumar_ @DavidKangni @Deb_Tripathy @Marcel_Szimonisz 

1 Reply

Avatar

Level 4

1st field code:

<li><label class="desc" id="title1">First Name <span class="req" id="req_4">*</span></label>
<div><input name="fname" class="inputwidth" id="fname" type="text" placeholder="First Name" data-nl-bindto="xpath" data-nl-xpath="@firstName" data-nl-ismandatory="true" data-nl-label="First Name" /></div>
</li>

2nd field code:

<li><label class="desc" id="title1">First Name <span class="req" id="req_4">*</span></label>
<div class="inputwidth"><input name="fname2" class="fname2" id="fname2" type="text" placeholder="First Name" data-nl-bindto="xpath" data-nl-xpath="@firstName2" data-nl-ismandatory="true" data-nl-label="First Name" /></div>
</li>

 

Mirroring script:

$("#mirror").change(function() {

var checkbox = document.getElementById('mirror').checked ;
if(checkbox = true){

var Pfirstname = document.getElementById("fname").value;


var Afirstname = Pfirstname;


document.getElementById("fname2").value = Afirstname;
}
else
{
document.getElementById("fname2").value = '';

}
});