Skip to main content
Skip table of contents

How to add an onMouseOver javaScript action to a TextField?

How can I add JavaScript actions to iText created textfields?

To add an onMouseOver JavaScript action to a TextField, use following code:

JAVA
TextField field = new iTextSharp.text.pdf.TextField(writer,
  new iTextSharp.text.Rectangle(x, y - h, x + w, y), name);
field.BackgroundColor = new BaseColor(bgcolor[0], bgcolor[1], bgcolor[2]);
field.BorderColor = new BaseColor(bordercolor[0], bordercolor[1], bordercolor[2]);
field.BorderWidth = border;
field.BorderStyle = PdfBorderDictionary.STYLE_SOLID;
field.Text = text; // PROBLEM:// field.AddJavaScript = PdfAction.JavaScript(// "this.getField(\"Total_0\"").value = ( this.getField(\""Quantity_0\"").value

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.