SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic JS - document.write to val(

    Hi,

    I have the following:

    Code:
    .....
    document.write(hours + minutes + day + month + year)
    
    jQuery(document).ready(function(){
    jQuery('#purchase_order').val('xxxxxxxx');
    ....
    I want to populate the xxxxxx with the result of the document.write

    I.e. I am generating a variable which is time & date, and want that in the val('xxxx') field

    It's probably very simple, but I'm short on js skills - thinking need to define the time/date as a variable and then populate that into val('') somehow?

    Many thanks in advance
    Rob

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Something like this?

    Code JavaScript:
    var set = hours + minutes + day + month + year;
    document.write(set);
     
    jQuery(document).ready(function(){
        jQuery('#purchase_order').val(set);
    });

  3. #3
    SitePoint Member
    Join Date
    Aug 2009
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Spot on, thank you heaps!!

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,197
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    No problem


Bookmarks

Posting Permissions

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