Select Page

I recently made changes to a web form that populated a PDF through an XFDF file. In the new code, instead of outputting to an XFDF, the page outputs to an HTML file. Everything worked great, except the HTML page lacked one feature the PDF did. If you have 2 fields with the same name on a PDF, when you update one field, the other field automatically gets the same content. This naming trick won’t work in HTML.
The sample code below will copy the contents of a textbox to another textbox without using JavaScript. The updates occur during each key press. I’ve include examples in standard HTML and ASP.NET. The red text is the code you use to copy one textbox to another.
HTML:

<form name="aForm" action="" method="" />
  <input type="text" name="TextBox1" onkeyup="document.aForm.TextBox2.value = this.value" />
  <input type="text" name="TextBox2" />
 </form>

ASP.NET:

<asp:TextBox ID="TextBox1" runat="server" onkeyup="document.aForm.TextBox2.value = this.value"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
Print Friendly, PDF & Email
Translate ยป