title: making script run for specific tabs in google spreadsheets
body: <p>I need some help with my code. I'm new to appscripts.
  I have a script that works wonderful. But i want to make it work in multiple tabs which will be duplicates of 'Layout 1'.</p>
  
  <p>I only want to make this script work in those 'Layout x' tabs. I have other tabs also.
  I made this script with help of a youtbe video. Edited to my liking and needs.
  But can't figure out how to make it work in other Layout Tabs.</p>
  
  <pre><code>var mainwsname = 'Layout 1';
  // tabs i want to edit below. Need help ?
  //var mainwsname = ['Layout 1', 'Layout 2', 'Layout 3', 'Layout 4', 'Layout 5', 'Layout 6', 'Layout 7', 'Layout 8', 'Layout 9', 'Layout 10', 'Layout 11', 'Layout 12'];
  var optionsname = 'Options';
  
  var firstLevelColumn = 8;
  var secondLevelColumn = 1;
  var thirdLevelColumn = 2;
  var fourthLevelColumn = 3;
  
  var ws= SpreadsheetApp.getActiveSpreadsheet().getSheetByName(mainwsname);
  var wsOptions= SpreadsheetApp.getActiveSpreadsheet().getSheetByName(optionsname);
  var options = wsOptions.getRange(2,1,wsOptions.getLastRow()-1,4).getValues(); //4 is getal aantal kolommen in options
  
  function onEdit(e)
  {
    var activeCell = e.range;
    var val = activeCell.getValue();
  
    var r = activeCell.getRow();
    var c = activeCell.getColumn();
    var wsname = activeCell.getSheet().getName()
    if (wsname === mainwsname &amp;&amp; c===firstLevelColumn &amp;&amp; r&gt;2)
    {
  
      applyFirstLevelValidation(val ,r);
    } else if(wsname === mainwsname &amp;&amp; c===secondLevelColumn &amp;&amp; r&gt;2)
    {
      applySecondLevelValidation(val ,r);
    }
  
  } // end onEdit
  
  function applyFirstLevelValidation(val ,r)
  {
    if (val === "")
      {
        ws.getRange(r, secondLevelColumn).clearContent();
        ws.getRange(r, secondLevelColumn).clearDataValidations();
         ws.getRange(r, thirdLevelColumn).clearContent();
        ws.getRange(r, thirdLevelColumn).clearDataValidations();
      }
      else{
      ws.getRange(r, secondLevelColumn).clearContent();
       ws.getRange(r, thirdLevelColumn).clearContent();
        ws.getRange(r, secondLevelColumn).clearDataValidations();
         ws.getRange(r, thirdLevelColumn).clearDataValidations();
      var filteredOptions = options.filter(function(o){return o[0]=== val});
      var listToApply= filteredOptions.map(function(o){return o[1]});
      var cell =ws.getRange(r,secondLevelColumn);
  
  
    applyValidationToCell(listToApply,cell);
      }
  }
  
  function applySecondLevelValidation(val ,r)
  {
    if (val === "")
      {
        ws.getRange(r, thirdLevelColumn).clearContent();
        ws.getRange(r, thirdLevelColumn).clearDataValidations();
  
        ws.getRange(r, fourthLevelColumn).clearContent();
        ws.getRange(r, fourthLevelColumn).clearDataValidations();
  
      }
      else{
      ws.getRange(r, thirdLevelColumn).clearContent();
      ws.getRange(r, fourthLevelColumn).clearContent();
  
      var firstLevelColValue= ws.getRange(r, firstLevelColumn).getValue();
      var filteredOptions = options.filter(function(o){return o[0]=== firstLevelColValue &amp;&amp; o[1]=== val});
      var thirdColumnValue= filteredOptions.map(function(o){return o[2]});
      var fourthColumnValue= filteredOptions.map(function(o){return o[3]});
  
       ws.getRange(r,thirdLevelColumn).setValue(thirdColumnValue);
       ws.getRange(r,fourthLevelColumn).setValue(fourthColumnValue);
  
      }
  }
  function applyValidationToCell(list,cell)
  {
  
    var rule = SpreadsheetApp.newDataValidation()
    .requireValueInList(list).setAllowInvalid(false)
    .build();
  
    cell.setDataValidation(rule);
  }
  </code></pre>