How to use a field label and value in code


I trying to use a function in order to kind of log IN A FIELD (not in a log file as this is a feature already in scriptcase by using the log functionality) any change in state of a field.

For instance if user change a select field value, I need to put in another field (a textarea field) :

“2021-09-30 => Field ‘myField_Label’ changed to ‘Field_Value_Selected’ .”

That would give in real life :

“2021-09-30 => Job Position changed to Administrator.”

where :

‘Job Position’ is the label of the field user_job
‘Administrator’ is the text of the value selected in the field user_job

I’m trying to write a function that will be called in the user_job onChange event (in scriptcase Ajax Events) like this :

function LogToField ($fieldname)
{myTextAreaField} = Date(“now”).’ => ‘.sc_label($fieldname).’ changed to '.{$fieldname};


I’m struggling for days now to get the correct syntax in vain. Can anybody help me please ?

Thank you to you all in advance.