Hi can anyone offer a complete newbie some information on prefilling a form with a date? (today in this instance)
I have a site, Joomla 1.0, not live yet + Chronoman 2.3.9 (?)
I found some Javascript that appears to fit the bill, and works as a standalone piece of code, in that when you view it in a browser the field is nicely filled with the date in dd/mm/yyyy format.
However when I paste the script, minus the script tags into the Form Code Tab/ Form Javascript area, it does not work.
The code enclosed in the <script> tags is :
var mydate = new Date()
var theyear = mydate.getYear()
if (theyear < 1000)
theyear += 1900
var theday = mydate.getDay()
var themonth = mydate.getMonth() + 1
if (themonth < 10)
themonth = "0" + themonth
var theday = mydate.getDate()
if (theday < 10)
theday = "0" + theday
var dd_part = themonth
var mm_part = theday
var yyyy_part = theyear
document.application_form.dateofregistration.value = dd_part + "/" + mm_part + "/" + yyyy_part
]And the form code is
<form name="application_form">
<label for="dateofregistration" class="left">Date Today (DD/MM/YYYY):</label>
<input type="text" name="dateofregistration" size=11>
</form>
Can anyone tell me if I'm missing something in the way the script should go into the Chronoforms admin area? I don't think it is syta, because the above works standalone. But having been wrong before on allsorts........
Thanks in advance.
Robmcp
I have a site, Joomla 1.0, not live yet + Chronoman 2.3.9 (?)
I found some Javascript that appears to fit the bill, and works as a standalone piece of code, in that when you view it in a browser the field is nicely filled with the date in dd/mm/yyyy format.
However when I paste the script, minus the script tags into the Form Code Tab/ Form Javascript area, it does not work.
The code enclosed in the <script> tags is :
var mydate = new Date()
var theyear = mydate.getYear()
if (theyear < 1000)
theyear += 1900
var theday = mydate.getDay()
var themonth = mydate.getMonth() + 1
if (themonth < 10)
themonth = "0" + themonth
var theday = mydate.getDate()
if (theday < 10)
theday = "0" + theday
var dd_part = themonth
var mm_part = theday
var yyyy_part = theyear
document.application_form.dateofregistration.value = dd_part + "/" + mm_part + "/" + yyyy_part
]And the form code is
<form name="application_form">
<label for="dateofregistration" class="left">Date Today (DD/MM/YYYY):</label>
<input type="text" name="dateofregistration" size=11>
</form>
Can anyone tell me if I'm missing something in the way the script should go into the Chronoforms admin area? I don't think it is syta, because the above works standalone. But having been wrong before on allsorts........
Thanks in advance.
Robmcp