SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2010
    0 Post(s)
    0 Thread(s)

    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


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

    Any help would be appreciated.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Christchurch, New Zealand
    102 Post(s)
    4 Thread(s)
    Start with the form, and an identifier for the form.

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

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

    Code javascript:
    var form = document.getElementById('order');
    var name = form.elements.firstname.value;
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2010
    0 Post(s)
    0 Thread(s)
    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$$&nbsp;&nbsp;&nbsp;$$F6$$</div>

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



    function is called here:
    <input type="submit" value="save" class="pbutton" onClick="prDate()" /> &nbsp;<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?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts