This topic is locked
[SOLVED]

 EDIT A FIELD IF EMPTY OTHERWISE READ ONLY

3/4/2014 6:14:24 AM
PHPRunner General questions
C
chrispa author

HI ,
I HAVE A TABLE NAMED tblsms AND WHAT I NEED IS WHEN I EDIT A RECORD , FIELD CALLED item CAN BE EDIT IF IS EMPTY , IF NOT EMPTY I.E.WHEN CONTAINS A VALUE TO BE READ ONLY.
PLS HELP
THANKS

W
wildwally 3/4/2014



HI ,
I HAVE A TABLE NAMED tblsms AND WHAT I NEED IS WHEN I EDIT A RECORD , FIELD CALLED item CAN BE EDIT IF IS EMPTY , IF NOT EMPTY I.E.WHEN CONTAINS A VALUE TO BE READ ONLY.
PLS HELP
THANKS


Yes this can be done utilizing simple if condition in the Javascript onload event. Something like this:



var ctrlitem = Runner.getControl(pageid, 'item');
if(ctrlitem .getValue() != '')

//do nothing or set to read write - remove comment if you want it to read write

//ctrlitem.makeReadWrite();

}else{

//force read only since field contains value

ctrlitem .makeReadonly();

}
C
chrispa author 3/5/2014



Yes this can be done utilizing simple if condition in the Javascript onload event. Something like this:



var ctrlitem = Runner.getControl(pageid, 'item');
if(ctrlitem .getValue() != '')

//do nothing or set to read write - remove comment if you want it to read write

//ctrlitem.makeReadWrite();

}else{

//force read only since field contains value

ctrlitem .makeReadonly();

}



thanks a lot !