I have a problem in utilizing inheritance properly for the following scenario. The inheritance chain is not correct. Yes, I know JS does not do multiple inheritance (although you can kinda fake it), this is not a multiple inheritance problem, or is it?


BACKGROUND:
I have a form with complex data relationships and I want to create objects to help corral the complexities. NOTE: We're using a "form building tool" called Liquid Office (LO), so I'm not working with HTML tags directly. But checkboxes, textboxes, etc. (hereafter referred to as "things") are exposed thru the LO interface.

I have 'mutually exclusive', 'mutually required' relationships etc. (hereafter refered to as "relationships"). Sometimes it's individual things that are related, sometimes it's groups of things that are related.

GENERAL APPROACH (so far!):
I want to be able to build individual things or sets of things and have relationships as needed. A "syncToMe(otherObject)" function will enforce the relationship. A "validate()" function will check for the relationship during form validation.

Wrap things as generic objects so that I have consistant functions "set()", unSet()", "enable()" etc. regardless of what kind of thing I'm dealing with. These methods are defined in the wrapper object and used in the relationship object

Next I want do define separate objects for each relationship. Each would have appropriate "validate()", "syncToMe()" functions for example.

Build individual "things" then "attach" the needed relationship to each thing. Thus I can enforce a relationship explicitly through either thing (or set of things) - for example each thing would invoke it's own "syncToMe()" function on it's "onClick" event.

I'm getting the feeling that I'm describing an abstract factory pattern, but not sure.

HERE IS THE GENERIC CODE
I'm including only one relationship, one thing, and an array of things but you get the idea.
PHP Code:
function oMutuallyExclusive (Msg) {
   
this.errorMsg Msg || "no Error Msg";
   
   
//don't override these functions
   
this.syncToMe = function (otherObject) {
      if (
this.isSet()) {
         
otherObject.unSet();
      }
      
      if (!
this.isSet()) {
         
otherObject.set();
      }
   } 
// syncToMe()   
   
   
this.validate = function (otherObject) {
      var 
isValid true;
      
      if(
this.isSet() && otherObject.isSet()) {
        
isValid false;  
      }
      
      if (!
this.isSet() && !otherObject.isSet()) {
        
isValid false;  
      }
      
      return 
isValid;
   } 
// validate()
// MutualyExclusiveObjects Object


function oArraySet (theThings) {
   
this.theObjects theThings;
   
   
this.set = function () {
      for (
i=0theObjects.lengthi++) {
         
this.theObjects[i].set();
      }
   } 
// set()
   
   
this.unSet = function () {
      for (
i=0this.theObjects.lengthi++) {
         
this.theObjects[i].unSet();
      }
   } 
// unSet()
      
   
this.enable = function (theState) {
      for (
i=0i<theObjects.lengthi++) {
        
theObjects[i].setReadOnly(theState);  
      }
   } 
//enable()
   
   
this.isSet = function () {
      var isSet = 
false;
      
      
nextObject:
      for (
i=0this.theObjects.lengthi++) {
         if (
this.theObjects[i].isSet()) {
            isSet = 
true;
            break 
nextObject;
         }
      }
      return isSet;
   } 
// isSet()
   
//oArraySetObject()

//liquid office specific
function oCheckbox (theCB) {
   
this.box theCB;
   
   
this.set = function (setting) {
      
this.box.setValue(arguments[0]);
   } 
//set()   
   
   
   
this.unSet = function (setting) {
     
this.box.setValue(arguments[0]);
   } 
// unSet()
   
   
   
this.isSet = function () {
      var isSet = 
true;
      
      if (
this.box.getValue() == 1) {
        isSet = 
true;  
      }else{
        isSet = 
false;
      }
      
    return isSet;
   } 
// isSet()
   
   
this.enable = function (theState) {
      
this.box.setReadOnly(theState);
   } 
//enable
}// oCheckbox 
Here is some code that expresses my intent. It does not work. The proper inheritance chain is not there.
PHP Code:
var myCB        = new oCheckbox(CSForm.getField("thecheckbox"));
var 
myText = new oTextbox (CBForm.getField("thetextbox"));

myCB.prototype        = new oMutuallyExlcusive;
myText.prototype = new oMutuallyExlcusive;

// an onclick event would be handled like this:
myCB.syncToMe(myText);