Populate PDF Form Textbox with Date/Time via Checkbox onclick

Greetings,

Checkbox = chkSubmit1
Textbox = txtDateTime1

I would like to have the textbox populate upon click of checkbox with date and time in m/d/yy h:MM tt format. I would also like the textbox field to be read-only at this point.

I have searched and the best I can find is:

if(event.value == "Yes")
this.getField("txtDateTime1").value = util.printd("mm/dd/yyyy",new Date());

I am a total JS newb and will need detailed instructions on implementing.

Thanks!!!


Douglas Stafford


Voted Best Answer

Add this code as the MouseUp event of your check-box:


var textField = this.getField("txtDateTime1");
if (event.target.value == "Yes") {
textField.value = util.printd("m/d/yy h:MM tt",new Date());
textField.readonly = true;
} else {
textField = false; // This is assuming you want to make the text field editable again when the check-box is unticked...
}

-------------------------------------
Visit my custom-made PDF scripts website: http://try67.blogspot.com
Contact me personally: try6767@gmail.com


By Gilad D (try67)   


Please specify a reason: