Printing a date from an input field

I am using a document imaging system to create a form. The form will be sent to the database, but also needs to be printed.

I am using HTML and CSS to create page breaks and print the name and ID number at the top of each page.

I do not have problem pulling the name and ID number because, I can pull them from the database.

I need to add the “date” to the top of each page. I need to pull the date from this field… <input type=“text” name=“date” />

I have tried several things

document.forms[0].getElementByName(‘name’).value.write

I know enough JavaScript to understand what is happening, but not enough to translate it to my needs.

Any help would be appreciated.

Start with the form, and an identifier for the form.


<form id="order" method="post" action="...">
    <fieldset>
        <legend>Info</legend>
        <p><label>First name: <input type="text" name="firstname"></label></p>
        ...
    </fieldset>
    ...
</form>

When scripting, it’s quite effective to use the form id to access the form values.


var form = document.getElementById('order');
var name = form.elements.firstname.value;
...

Thank you for the clarification.

I am still having difficulty writing the function.
Snippets from HTML code:

<form action=“$$URL$$” method=“post” id=“tak” >

<tr><td colspan=“5”>Date: <input type=“text” name=“takdate” value=“$$takdate$$” class=“sp5” /></td>

This is where I want the name=“takdate” to print:

<div class=“break prRight”>Page _____ of _____ <br /> $$F1$$   $$F6$$</div>

Do I embed the function like this?
<div class=“break prRight”>Page _____ of _____ <br /> $$F1$$   $$F6$$ <br />
<script language=“javascript” type=“text/javascript”>
function prDate(){
var form = doument.getElementById(‘tak’);
var date = form.elements.takdate.value;

document.write(‘date’);

}
</script>
</div>

function is called here:
<input type=“submit” value=“save” class=“pbutton” onClick=“prDate()” />  <input type=“button” value=“print” class=“pbutton” onClick=“window.print()” />

This does not write the ‘takdate’.

I also added <input type=“hidden” value=“takdat” />

This did not work either.

Any suggestions?