Forums

Value of Readonly field in HTML email & database

hughesie 10 Nov, 2012
I have a text field on my form that has the current date and time. I have set this field to be read only. I would like to save this value in the Database and I would like to include this value in the email that is sent but the value is never passed via email or to the database.

I'm setting this field to readonly with some JS onload. If I don't make it readonly it saves and emails the value.

window.addEvent('load', function() {
// function to enable and disable the submit button

// disable the submit button on load
$('txtDateTimeReferral').readOnly = true;
});

I'd like to keep it as readonly and still email and save the value, any suggestions?

Thx,

Jonathan
GreyHead 11 Nov, 2012
Hi Jonathan,

If you created the database table with ChronoForms then the date and time will be saved in the recordtime column. You could pick this value up and use it in the email.

A read only input should work OK and the code you have there looks OK. I can check it when I'm back in the office in the next couple of days.

Bob
hughesie 12 Nov, 2012
I had to remove the readonly attribute to get it to save or email the data for that field.

Let me know what you find out.

Thx,

Jonathan
GreyHead 22 Nov, 2012
Hi Jonathan,

This appears to be working OK, see my test form here. The input has the named & id txtDateTimeReferral and the JavaScript is
window.addEvent('domready', function() {
  $('txtDateTimeReferral').readOnly = true;
});

If you submit the form you can see the date+time in the submitted debug data.

Bob
hughesie 22 Nov, 2012
Yes I believe I saw that as well, re: Debug. It just doesn't save the data in the DB and it doesn't show in the email. It only worked after I removed readOnly.
GreyHead 23 Nov, 2012
Hi Jonathan,

Your JavaScript or a readonly attribute setting can't have any affect after the form is submitted. If the data is present in the $form->data array shown in the debug then it is available to save and to email.

Bob
This topic is locked and no more replies can be posted.