Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

[JS][CS4] - Conditional statements in a table?

$
0
0

Hello,

 

I am trying to write a script that looks at the content of the last column of a table and based on what it finds applies formatting to the first column, for every row of the table.

 

For example, in each row if the last column has a 6 digit number that starts with "4" I want the first column to apply one of my swatches.  If the number starts with a "3" I want it to apply a different swatch.

 

I tried using the regular expression object since I'm fairly comfortable with GREP syntax but I keep getting errors.  I just don't know how to use the object correctly or if this is even the right approach.

 

Here is the code:

 

if (myTable.rows.item().everyItem().cells.item(-1).contents == RegExp((4)+\d+))

     {myTable.rows.item().everyItem().cells.item(0).fillColor = myDocument.swatches.item("Blue");}

 

I am brand new to scripting so very open to any help.

 

Thanks!

Lindsay


Viewing all articles
Browse latest Browse all 15932

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>