In your original solution, what user action triggered the script?
Clicking on the "Referred by type" field popped up a drop down list with three options:
Upon selection of one of the three values for the "Referred by type" field the "if" calculation was run and the relevant script was triggered leading to the relevant layout
Take your pick: either OnObjectExit or OnObjectSave could be used to trigger a script to do this when you select from a drop down list. If it's a pop up menu, you can use OnObjectModify for this.