Make a filed as readonly
Make a filed as readonly
i want to make a primary key field as readonly to prevent any update after initial entry. Appini is allowing to make the readonly all the time. Is it possible to make the field readonly after initial value is entered?
-
- AppGini Super Hero
- Posts: 85
- Joined: 2014-06-14 03:08
- Location: India
- Contact:
Re: Make a filed as readonly
Hi,
You better keep the primary key field as auto increment and Readonly,
Or
You can use magic hooks file and disable the field.
You better keep the primary key field as auto increment and Readonly,
Or
You can use magic hooks file and disable the field.
Re: Make a filed as readonly
thanks uday. any sample code is appreciated. i would like to use magic hooks
table.field.property== readonly will work?
table.field.property== readonly will work?
-
- AppGini Super Hero
- Posts: 85
- Joined: 2014-06-14 03:08
- Location: India
- Contact:
Re: Make a filed as readonly
create <tablename>-dv.js file and put in hooks folder
content of file should be
content of file should be
Code: Select all
document.getElementById("<id of the text box>").readOnly = true;
Re: Make a filed as readonly
Sorry its not working, actually i want to make this field to readonly in update mode. the filed name is "Jobnumber".
I created a new file MainTable-dv.js (MainTable is table name) in hooks folder and created as above line. but this is not having any effect. what i am doing wrong?
Code: Select all
document.getElementById("Jobnumber").readOnly = true;
Re: Make a filed as readonly
is it possible to use function MainTable_before_update() to make this field readonly? i have tried "'MainTable'.'Jobnumber'.Disabled = true;" and "'MainTable'.'Jobnumber'.readOnly = true;" but both of them not working
Code: Select all
function MainTable_before_update(&$data, $memberInfo, &$args){
'MainTable'.'Jobnumber'.Disabled = true;
return TRUE;
}
Re: Make a filed as readonly
Thanks uday done it
Code: Select all
if(document.getElementById("Jobnumber").value!=""){
document.getElementById("Jobnumber").readOnly = true;
}
-
- AppGini Super Hero
- Posts: 85
- Joined: 2014-06-14 03:08
- Location: India
- Contact:
Re: Make a radio button Read Only after selection
Following on from this thread, I had the need to make a radio button selection disabled (read only) after the selection was made. Here's what eventually worked for me.
Let's say you have 3 x radio buttons (None, Yes & No). You want the selection to become read-only (disabled) after the selection is made & saved.
Firstly, determine the ID's of the radio buttons that have been created by Appgini (use Firebug or your browser developer tools). The radio buttons are generated in Appgini from a <%%COMBO(radio-field-name)%%> command so it is not obvious to start with.
Then, in YourTableName-dv.js add the following;
(function () {
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', domReady, false);
} else {
window.attachEvent('onload', domReady);
}
} ());
function domReady() {
if(document.getElementById("yourradioID2").checked){
document.getElementById("yourradioID1").disabled = true;
document.getElementById("yourradioID3").disabled = true;
}
if(document.getElementById("yourradioID3").checked){
document.getElementById("yourradioID1").disabled = true;
document.getElementById("yourradioID2").disabled = true;
}
}
That's it. If "Yes" is selected, then "None" and "No" are now disabled. Likewise if "No" is selected. The DOMContentLoaded function is required as a "null" Javaccript error is returned otherwise.
Hopefully that may prove useful to somebody other than me.
PS: The DOMContentLoaded function is HTML5 and apparently won't work in old Internet Explorer pre Version 8. There are workarounds but not necessary as far as I'm concerned. Works on every other modern browser.
Let's say you have 3 x radio buttons (None, Yes & No). You want the selection to become read-only (disabled) after the selection is made & saved.
Firstly, determine the ID's of the radio buttons that have been created by Appgini (use Firebug or your browser developer tools). The radio buttons are generated in Appgini from a <%%COMBO(radio-field-name)%%> command so it is not obvious to start with.
Then, in YourTableName-dv.js add the following;
(function () {
if (window.addEventListener) {
window.addEventListener('DOMContentLoaded', domReady, false);
} else {
window.attachEvent('onload', domReady);
}
} ());
function domReady() {
if(document.getElementById("yourradioID2").checked){
document.getElementById("yourradioID1").disabled = true;
document.getElementById("yourradioID3").disabled = true;
}
if(document.getElementById("yourradioID3").checked){
document.getElementById("yourradioID1").disabled = true;
document.getElementById("yourradioID2").disabled = true;
}
}
That's it. If "Yes" is selected, then "None" and "No" are now disabled. Likewise if "No" is selected. The DOMContentLoaded function is required as a "null" Javaccript error is returned otherwise.
Hopefully that may prove useful to somebody other than me.
PS: The DOMContentLoaded function is HTML5 and apparently won't work in old Internet Explorer pre Version 8. There are workarounds but not necessary as far as I'm concerned. Works on every other modern browser.