html:javascript simple question
Hi, In my jsp's i do on the bottom of the jsp: script today(); /script In my head section i then define the method... function today(){ var today = new Date(); var month = today.getMonth()+1; var year = today.getYear(); var day = today.getDate(); if(day10) day = 0 + day; if(month10) month= 0 + month ; if(year1000) year+=1900; var date=day + / + month + / + year; window.document.forms[0]'shipments.shipmentDate'].value=date; } This is working fine, but thaught might there be a better way doing this ? Using html:javascript ? Thanks !! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html:javascript simple question
the DateTime taglib would perfectly fit your needs: http://jakarta.apache.org/taglibs/doc/datetime-doc/intro.html Ben -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 19 februari 2004 11:27 To: [EMAIL PROTECTED] Subject: html:javascript simple question Hi, In my jsp's i do on the bottom of the jsp: script today(); /script In my head section i then define the method... function today(){ var today = new Date(); var month = today.getMonth()+1; var year = today.getYear(); var day = today.getDate(); if(day10) day = 0 + day; if(month10) month= 0 + month ; if(year1000) year+=1900; var date=day + / + month + / + year; window.document.forms[0]'shipments.shipmentDate'].value=date; } This is working fine, but thaught might there be a better way doing this ? Using html:javascript ? Thanks !! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: html:javascript simple question
Or with JSTL: %@ taglib prefix=fmt uri=http://java.sun.com/jstl/fmt; % jsp:useBean id=today class=java.util.Date/ script type=text/javascript language=javascript !-- function today() { var date = fmt:formatDate value=${today} pattern=dd/MM//; window.document.forms[0]['shipments.shipmentDate'].value = date; } // -- /script But seeing as how this is a Struts list, why not handle it in ActionForm.reset (or wherever else you might be initializing the form's data)? Quoting Turner Benjamin [EMAIL PROTECTED]: the DateTime taglib would perfectly fit your needs: http://jakarta.apache.org/taglibs/doc/datetime-doc/intro.html Ben -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: 19 februari 2004 11:27 To: [EMAIL PROTECTED] Subject: html:javascript simple question Hi, In my jsp's i do on the bottom of the jsp: script today(); /script In my head section i then define the method... function today(){ var today = new Date(); var month = today.getMonth()+1; var year = today.getYear(); var day = today.getDate(); if(day10) day = 0 + day; if(month10) month= 0 + month ; if(year1000) year+=1900; var date=day + / + month + / + year; window.document.forms[0]'shipments.shipmentDate'].value=date; } This is working fine, but thaught might there be a better way doing this ? Using html:javascript ? Thanks !! -- Kris Schneider mailto:[EMAIL PROTECTED] D.O.Tech http://www.dotech.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]