Is it possible to store some javascript into a field and then call it from a method that will be completed by this code?
That is possible, you have to use eval for that:
eval(fieldname);
Be aware that allowing users to write their own code is a serious security risk!