Link to home
Start Free TrialLog in
Avatar of David Megnin
David MegninFlag for United States of America

asked on

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!!!
ASKER CERTIFIED SOLUTION
Avatar of kirankumar_goura
kirankumar_goura
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of David Megnin

ASKER

Hi.  I see steps 2. and 3.  Is there supposed to be a step 1. ?
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

Thanks.