Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Go to cell and alert contents

Guest
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Hi, I want to find and alert contens of a cell in a table. Matrix method.

I found a stupid idea to find it.

Well i could get the Number of Column and row. but i cant able to select the contents of a cell (3,1).

(I'm trying to get alert of a content which is having header "Mate" and reference number 71247.

TitleSongMateFilmTwo
50%25050027052071247
11%125FeckeriNJAMANRAH71248
13222IQUEWATERWAFER71246
UNIQUEFARESTFARTABVALUE71249

var every = app.activeDocument.pages.everyItem(0).textFrames.everyItem().tables.everyItem().cells.everyItem().getElements();

var T = [];

var m = [];

for(i=0; i<every.length; i++) {

if(every.contents =="Mate") {

app.findGrepPreferences.findWhat = "71247";

          app.activeDocument.findGrep(true);

          var fnd = app.activeDocument.findGrep();

      for(y=0; y<fnd.length; y++) {

                    if(fnd.length>0 &&

            T.push(fnd.parent.name));

            m.push(every.name);

                    var f= (m).join("\r").replace(":", ".");

                    var e = (T).join("\r").replace(":", ".");

                     var u = e-f;

                    var n = [];

                    n.push(u);

             }

}

}

alert(n);

Many thanks for the support.

TOPICS
Scripting

Views

704
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Enthusiast , Mar 15, 2014 Mar 15, 2014

If you want to find 500 try this:

var curDoc = app.activeDocument;

var everyHeaderRow = curDoc.pages.everyItem(0).textFrames.everyItem().tables.everyItem().rows[0].getElements();

for( var i = 0; i<everyHeaderRow.length; i++ ) {

  var curHR = everyHeaderRow;

  var allHC = curHR.cells;

   

for ( var j = 0; j < allHC.length; j++ ) {

  if ( allHC.contents == "Mate" ) {

    var curCol = allHC.columns[0].index;

    var curTableCells = curHR.parent.cells;

      for ( var c = 0; c < curTableCells.length; c++ ) {

 

...

Votes

Translate
Enthusiast ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Hi,

first I realize that with InDesign CC everyItem() is verry slow, even I have only two tables on one page?!

Why has your last column no header "Mate"? If I understand the question correct, I would do it in this way:

var curDoc = app.activeDocument;

var everyHeaderRow = curDoc.pages.everyItem(0).textFrames.everyItem().tables.everyItem().rows[0].getElements();

for( var i = 0; i<everyHeaderRow.length; i++ ) {

  var curHR = everyHeaderRow;

  var allHC = curHR.cells;

   

for ( var j = 0; j < allHC.length; j++ ) {

  if ( allHC.contents == "Mate" ) {

    var curCol = allHC.columns[0];

      for ( var c = 0; c < curCol.cells.length; c++ ) {

        var curCell = curCol.cells;

          if ( curCell.contents == "71247" ) {

            curCell.select();

            var cellName = curCell.name;

            var co = Number(curCell.name.split(":")[0])+1;

            var ro = Number(curCell.name.split(":")[1])+1;

            alert("Found\r" + "Column: " + co + "\r" + "Row: " + ro + "\r" + "Contents: " + curCell.contents);

         }

      }

    }

  }

}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Sorry for the confusion Kai,

I do want to find the contents which is in column "Mate" and row 71247.

just a x-y co-ordinates which meet at the column Mate and Row which has cell contents "71247"

Untitled-1.jpg

thanks for the reply Kai.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

@Unique – every cell has a parentRow property. So if you found a cell, look at its parentRow.cells[-1] to get the last cell of that parent row and read out its contents.

Uwe

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

@Unique – there is a fantastic documentation of the DOM (Document Object Model) where you can look up all properties and methods for the objects. I recommend downloading the chm-files, because they are  easily searchable:

Jongware

InDesign JavaScript Reference Guide

http://www.jongware.com/idjshelp.html

Uwe

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

If you want to find 500 try this:

var curDoc = app.activeDocument;

var everyHeaderRow = curDoc.pages.everyItem(0).textFrames.everyItem().tables.everyItem().rows[0].getElements();

for( var i = 0; i<everyHeaderRow.length; i++ ) {

  var curHR = everyHeaderRow;

  var allHC = curHR.cells;

   

for ( var j = 0; j < allHC.length; j++ ) {

  if ( allHC.contents == "Mate" ) {

    var curCol = allHC.columns[0].index;

    var curTableCells = curHR.parent.cells;

      for ( var c = 0; c < curTableCells.length; c++ ) {

        var curCell = curTableCells;

          if ( curCell.contents == "71247" ) {

            var curRow = curCell.parentRow.index;

                    var x = curCol + ":" + curRow;

                    var curName = curTableCells.item(x);

            alert(curName.contents);

         }

      }

    }

  }

}

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

Hi Laubender & 5.Kai Rübsamen,

Many apologise for my request.

I m not a programmer like you people.

I tried in this way before i got answer from you people.

var every = app.activeDocument.pages.everyItem(0).textFrames.everyItem().tables.everyItem().cells.everyItem().getElements();

// Would be so cool:

var T = [];

var m = [];

var sn = [];

for(i=0; i<every.length; i++) {

if(every.contents =="71247") {

//~

app.findGrepPreferences.findWhat = "Null";

          app.activeDocument.findGrep(true);

          var fnd = app.activeDocument.findGrep();

          for(y=0; y<fnd.length; y++) {

                    if(fnd.length>0 &&

                    T.push(fnd.parent.name));

                    m.push(every.name);

                    var f= (m).join("\r").replace(":", ".");

                    var e = (T).join("\r").replace(":", ".");

                    r = [];

                    r.push(e.split('.')[0]);

                    //alert (r);

 

g = [];

                              g.push(f.split('.')[0]);

          //alert(g);

                    var u = f-e;

                    var n = [];

                    n.push(u);

                    Found = [];

                    Found.push(g-r);

                    app.select((every[i-Found]));

                    sn.push(every[i-Found].contents);

      }

}

}

alert (sn);

Sorry for troubling you guys. I want to learn the proper method to create script like you people have created. I m really happy the way you have presented. and im ashamed of what i have done. but i want to simply my method.

Laubender. As far i known, whenever anyone post in the forum you and jump_over [jareak] would always answer for any kind of stupid questions.

thanks Laubender and let me know how can i learn from you.

my id. is. raji27_siva@yahoo.co.in.

many thanks.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 15, 2014 Mar 15, 2014

Copy link to clipboard

Copied

LATEST

i got what i need from you,

Kai Rübsamen,

my is is raji27_siva@yahoo.co.in.

many many thanks or this kai.... please keep in touch with me...

Go to cell and alert contents

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines