Results 1 to 3 of 3

Thread: putting javascript in a disabled text box in php..

  1. #1
    Join Date
    Aug 2006
    Posts
    65
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default putting javascript in a disabled text box in php..

    I cant seem to figure out how to put this javascript code into the disabled text box... the javascript code automatically fills in todays date..

    here is the disabled text box
    Code:
    <tr><td width="73">Event Date:</td>
    <td width="715"><input name=date type=text disabled value="Todays Date">
    </td></tr>

    and here is the javascript code
    Code:
    <SCRIPT Language="JavaScript">
    <!-- hide from old browsers
      var today = new Date()
      var month = today.getMonth()+1
      var year = today.getYear()
      var day = today.getDate()
      if(day<10) day = "0" + day
      if(month<10) month= "0" + month 
      if(year<1000) year+=1900
         
      document.write(month + "/" + day +
                     "/" + year) 
    //-->
    </SCRIPT>
    can someone show me how to put in it the disabled text box

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    Code:
    <SCRIPT Language="JavaScript">
    <!-- hide from old browsers
      var today = new Date()
      var month = today.getMonth()+1
      var year = today.getYear()
      var day = today.getDate()
      if(day<10) day = "0" + day
      if(month<10) month= "0" + month 
      if(year<1000) year+=1900
         
      document.write("<input name=date type=text disabled value=" + month + "/" + day + "/" + year + ">") 
    //-->
    </SCRIPT>
    Try putting that in the body where you want the date to show up. If that does not work. sorry, but im better at PHP than Javascript. Another thing you could try is using the php date() function instead of javascript.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Aug 2006
    Posts
    65
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    thanks man.. I didnt know there was a function that already did the date for me..

    Thanks

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
  •