Last time we talked about hiding fields in the editform, newform and dispform. But what if we don’t want to hide a certain field, but rather get some value and put it in? An example could be to fill in a unique number or the day of the week.
Code
First, add the reference to the jquery file on your page. Next, add the code:
<script> $(document).ready(function() { var fieldToAddText = $(":input[title='Your Fieldname']"); if( fieldToAddText .val() != undefined ) { fieldToAddText .val("add some text"); }; }; </script>
What this code does, is simply: when the page is loaded, get the field where the name of the field is a certain value. If the field exists, write something in the textfield.