Log in

View Full Version : putting javascript in a disabled text box in php..



Humper
09-07-2006, 02:39 PM
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

<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

<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

thetestingsite
09-07-2006, 03:55 PM
<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() (http://php.net/date) function instead of javascript.

Humper
09-07-2006, 04:34 PM
thanks man.. I didnt know there was a function that already did the date for me..

Thanks