0 Replies Latest reply on Dec 1, 2010 8:05 AM by AaronGHawkins

    [CS4][JS] Apply methods to selected cells (Please help!)


      I've been working on a catalog with some massive data tables. I've got a couple scripts that seem to be working fine, but I'd like to see if someone could help optimize them with me. Currently, each script goes through the entire table, cell by cell, and applys a cell style based on the content of the cell. The other script goes cell by cell and if empty, merges it with the cell above it. The issue is that I still have to go cell by cell to delete duplicated data. I'd like to see if there's a way to only run the script on selected rows that accomplishes the proposed algotith below. I'm new to JavaScript but proficient in Indesign and other programming languages. Any help is greatly appreciated and I'll gladly help anyone in any way I can.


      I think the algorithm would be something like:

      1. User selects an array of rows and runs script
      2. Script scans cell contents
        • Case 1: if "Red," apply cell style "colorRed"
        • Case 2: if "Brown," apply cell style "colorBrown"
        • Case 3: etc etc etc
      3. Script compares Col X:Row1 (cellOne) with Col X:Row2 (cellTwo)
      4. If cellOne and cellTwo are equal, delete contents of cellTwo and merge with cellOne
      5. Loop #3 and #4 until end of column
      6. Move to next column, goTo #3
      7. Loop until end of user selection in reached

      The current state is:


      familynamestatuscolor hair



      The desired state is (after selecting Family Jones and running script then selecting family Smith and running script):


      familynamestatuscolor hair