How can we make an input field readonly?

Posted by Rollbase User on 29-Jan-2011 12:10

How can we make an input field readonly? There is an option to make a field readonly in Page Editor, however it translates the field in HTML text instead of making the HTML input box readonly. I am tring to make the following: I need this for a dynamic form.

All Replies

Posted by Admin on 30-Jan-2011 14:48

You can use client-side script:

theForm.myField.disabled=true;

Posted by Admin on 15-Nov-2012 01:59

I have the same question about of making readonly fields,

if i use theForm.myField.disabled=true; the value will not be save.

Posted by Admin on 15-Nov-2012 11:33

To send data back to browser you'll need tag.

Posted by Admin on 15-Nov-2012 21:22

I was able to achieve what you looking to do using this trick:



In the object definition, you specify a JavaScript Event Handlers for the field you want the behave as readonly.



Enter the following in the onfocus handler :

onfocus = " this.readOnly=true; this.blur(); "





It would be nice to have this trick integrated as a new build-in feature.



Posted by Admin on 15-Nov-2012 21:41

Hi



Another way to go about this is to set readonly when the page loads.



onload property of the page:

document.theForm.fieldName.readOnly = true;



as per experience some browsers reject the code above so we use:



document.theForm.fieldName.readOnly = 'readonly';



You can apply both if need be. Just to be sure that the field is set to readonly. Additionally using readonly will still save the data within the field unlike disabled.



Hope this helps

Piscoso, Martin

Rollbase

This thread is closed