How to copy contents of one text box to another text box inside a FormView if CheckBox is checked using JavaScript

Inside <asp:FormView ID="FormView1" FormView1, in the <EditItemTemplate>
I have two TextBoxes:
<table><td><asp:TextBox ID="SSNTextBox" runat="server" Text='<%# Bind("SSN") %>'/>
... and ...
<asp:TextBox ID="VerifySSN" runat="server" Text="" />

Also in the EditItemTemplate there's a CheckBox:
<asp:CheckBox ID="cbVerify" runat="server" Checked='<%# Bind("Verify") %>' />

When the page loads, if the CheckBox is checked I need to put the contents of TextBox "SSNTextBox" into TextBox "VerifySSN" with JavaScript

Please show me how to do that.  Thank you!!!
Who is Participating?
kirankumar_gouraConnect With a Mentor Commented:
2.In the head section add the following code
<script language = "javascript" type= "text/javascript">
 function ClickSample()
     var txtSSNValue = document.getElementById('<%=SSNTextBox.ClientID %>').value;
     var txtVerifySSN = document.getElementById('<%=VerifySSN.ClientID %>');
     txtVerifySSN.value = txtSSNValue;
</script>3.On the page load add the following.

cbVerify.Attributes.Add("onclick", "return ClickSample();");

megninAuthor Commented:
Hi.  I see steps 2. and 3.  Is there supposed to be a step 1. ?
megninAuthor Commented:
Oh, I don't want the text copied from one textbox to the other WHEN the checkbox is checked.  I only want to TEST the checkbox on PageLoad, and IF it is checked copy the contents of the first textbox to the second text box.  If the check box is not checked I don't want to do anything.

I coud do it about like this in VB, but I want to do it client side.

On PageLoad
   If cbVerify.Checked = true Then
       VerifySSN.Text = SSNTextBox.Text
   End If

All Courses

From novice to tech pro — start learning today.